aligned correct IE, not in firefox

Discussion in 'CSS' started by buck, Jan 30, 2008.

  1. #1
    Before adding this little code i found online to the css it was aligned left in both firefox and IE, which i do not want, i'd prefer it be centered because it looks like crap on a larger monitor.
    body {
    	margin:0px auto; padding:0px;
    	text-align:center;
    
    }
    content
    {
    margin:0px auto;
    }
    Code (markup):
    after adding that it centers in IE, but still huggin the left side of the screen in firefox... any clue at all?
     
    buck, Jan 30, 2008 IP
  2. donross

    donross Active Member

    Messages:
    90
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    98
    #2
    the clue is you missed a period before class/id name content ... it should be .content or #content
     
    donross, Jan 30, 2008 IP
  3. buck

    buck Peon

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no that has no effect..
     
    buck, Jan 31, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Did you set a width on anything? It's possible Firefox is able to make a good guess as how wide the thing is, while IE doesn't even try. A width should be set before asking a browser to calculate how much margin to have on each side.
     
    Stomme poes, Jan 31, 2008 IP
  5. jorgy

    jorgy Peon

    Messages:
    611
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try :
    body
    {
    text-align: center;
    }
    #content //# is used to define a division
    {
    margin: 0 auto;
    }
     
    jorgy, Feb 1, 2008 IP
  6. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #6
    <div id="content">Yo.</div>

    #content { margin:0 auto; width:600px; }

    That would be horizontally centered if the browser is rendering the page in standards/almost standards mode.

    Ignore the text-align. It's 2008. Fuck ie5.x and ie6 quirks.
     
    soulscratch, Feb 1, 2008 IP
  7. jorgy

    jorgy Peon

    Messages:
    611
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Agreed, and yes, this should work.
     
    jorgy, Feb 1, 2008 IP
  8. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Aha yes, if the above didn't fix the issue, then likely IE6 is in quirks mode (anything before the doctype, or, no doctype anyway).

    If "text-align: center" on the body works for centering in IE6, then that's the issue, quirks mode. I should have thought to mention it.
     
    Stomme poes, Feb 3, 2008 IP