centering problem with div

Discussion in 'CSS' started by tilto, Mar 20, 2008.

  1. #1
    Hi,
    i would like to center a container, and it works fine in FF. But when i look at my site in IE the container is on the left side of the screen. could someone please have a look and give me a hint?
    thanks in advance!
     

    Attached Files:

    tilto, Mar 20, 2008 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't open zips but do you have a valid doctype with no spaces or text or anything before it?

    If you are using margin: 0 auto on this container and FF shows it centered, but IE not, I'm guessing something is throwing IE into Quirks mode because when it's in "standards" mode (or what IE calls "standards"), that centering should also work.

    Never works for IE5.5 and below. If you care about them, the trick is
    body {
    text-align: center;
    }
    Which is only supposed to center inlines but in old IEs it also centers blocks. If this works in IE6 then it's definitely in Quirks mode! Get it out of there!
    next container or wrapper {
    text-align: left;
    }
    if you really don't want the text centered on the whole page.
     
    Stomme poes, Mar 20, 2008 IP
  3. tilto

    tilto Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i have to use
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:\//www.w3.org/TR/html4/loose.dtd"> because of some javascript in the page, else it wont pass the validator.

    have a look here please :

    html:
    http://pastie.caboo.se/private/xq0qekbxwjnuvbmcuc1eg
    css:
    http://pastie.caboo.se/private/rr28n6fa9tfdjmh85nfjkg
     
    tilto, Mar 20, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Still waiting for the page to load but Transistional is fine. The point is, when the page is being looked at by the browser (when you click View Source), is there anything, even a space, before the doctype? IE sees something other than <!D... as the first thing and goes immediatly into Quirks Mode (even though there's a doctype).
     
    Stomme poes, Mar 20, 2008 IP
  5. tilto

    tilto Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    the very first character of the page is "<".
    have a look at the attachments please, but rename the mycss.css.html to .css first.
     

    Attached Files:

    tilto, Mar 20, 2008 IP
  6. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Okay, hah! This one's easy. You have a typo.

    You have:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:\//www.w3.org/TR/html4/loose.dtd">
    See that slash after http:?
    You need:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

    Done : )

    Tested: http://stommepoes.nl/testtt.html

    (I'm only going to keep that site on my server for a while, long enough for you to see the effects... my background is sitting in the middle of the page : )
     
    Stomme poes, Mar 20, 2008 IP
  7. tilto

    tilto Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks dude, you really saved my day. i wonder why i didnt see that for myself.
     
    tilto, Mar 20, 2008 IP
  8. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I didn't see it for a while either. Typos have bit me in the butt before too.
     
    Stomme poes, Mar 20, 2008 IP