How i can center this DIV?

Discussion in 'CSS' started by redhits, May 24, 2008.

  1. #1
    redhits, May 24, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Sorry, cannot connect.

    cheers,

    gary
     
    kk5st, May 24, 2008 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I can, Gary.

    First off, start by using a complete and proper DOCTYPE. You should also learn how to use HTML properly as well (for example, your menu is a list of links - mark it up as such; another one is that you forgot to close your HTML tag). Absolute positioning is not acceptable (or even practical) for general layouts, and well, generally, I'd just toss the whole thing out and start over. Fortunately you don't have much there to begin with, so there won't be much to replace.
     
    Dan Schulz, May 25, 2008 IP
  4. ferman

    ferman Well-Known Member

    Messages:
    968
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #4
    to center the div you have to set its right and left margin auto

    i.e

    div { margin:0px auto;

    }
     
    ferman, May 26, 2008 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That will only work if two conditions have been met: The presence of a complete and proper DOCTYPE, and a width being explicitly declared on the DIV. Note that by targeting "div" by itself, EVERY DIV will inherit this styler ule, which is not what the OP wanted.
     
    Dan Schulz, May 26, 2008 IP