1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Centering a Layer

Discussion in 'CSS' started by Jim bob 9 pants, May 16, 2005.

  1. #1
    Hello,

    Can anyone help me here, I would like to know firstly how to postion a layer centrally on a page, then how to do it in css - I have been searching and got know where, trawled all through the zen garden but cannot fathom how to use css to centre layer

    Thank you in advance
    SEMrush
    Jim Bob :confused:
     
    Jim bob 9 pants, May 16, 2005 IP
    SEMrush
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Block level elements are supposed to be centered setting their left and right margins to "auto". You can find more details on this in the thread 7061.

    J.D.
     
    J.D., May 17, 2005 IP
  3. cristophe@lawyer.com

    cristophe@lawyer.com Guest

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I find this to usually be my savior:

    html, body{
    text-align:center;
    }
    Code (css):
    Good Luck!
     
    cristophe@lawyer.com, Aug 30, 2005 IP
  4. aqi32

    aqi32 Active Member

    Messages:
    225
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    text-align:center; doesn't work cross browser, use auto margins and text-align together to ensure cross browser centering, you need a containing element with the text-align:center though :)
     
    aqi32, Sep 6, 2005 IP
  5. bgolat

    bgolat Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    easiest way, set the width you want the layer, the for left and right margin set them to auto.
     
    bgolat, Sep 6, 2005 IP
  6. mikmik

    mikmik Guest

    Messages:
    356
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you want one box only, exactly centered, you can do absolute position.

    Say :
    So now, notice width="600px"
    Add this to '#centered_Div'

    !!! Margin is equal to -1/2 of width and/or height when position=50%
     
    mikmik, Sep 10, 2005 IP