REALLY simple center problem

Discussion in 'CSS' started by le007, Mar 21, 2012.

  1. #1
    Hi all,

    I just need a really simple box-like container. I need it to be centered, regardless of resolution or browser.
    I've tried this code below but it's not really working - any suggestions?


    Thanks


    html, body {
    height: 100%;
    background: url(grey.jpg)
    }
    
    #container {
    min-height: 100%;
    width: 1000px;
    margin: 0 auto;
    font-family: sans-serif;
    background-color: black;
    }
    * html #container {height: 100%;} /*no min-height for lte IE6*/
    
    Code (markup):
     
    Solved! View solution.
    Last edited: Mar 21, 2012
    le007, Mar 21, 2012 IP
  2. #2
    What doctype are you using for your html document?

    also what browsers is it not working for?

    if no doctype is declared and you load that into IE it won't center, but if you do a doctype of xhtml transitional it should center.

    so I suggest trying this at the top of your file.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    Code (markup):
     
    Devitor, Mar 21, 2012 IP
  3. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Hi Devitor,

    Got it in one. Thanks very much
     
    le007, Mar 22, 2012 IP
  4. Devitor

    Devitor Peon

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    0
    #4
    No problem, It is a very common mistake. Just make sure you you do things like that and it works in one browser but not another check the w3 site, they have nice charts for what works with which doctype.
     
    Devitor, Mar 22, 2012 IP
  5. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Will do, cheers ",)
     
    le007, Mar 22, 2012 IP