Why does margin-left:auto; margin-right:auto; not work in IE

Discussion in 'Programming' started by Glenn, Jan 31, 2012.

to remove all ads.
  1. Glenn

    Glenn Member

    Messages:
    202
    And how do I get things to center up in IE?
     
  2. Phreaddee

    Phreaddee Super Moderator Staff Member

    Messages:
    1,978
    How long is a piece of string?
    What version?
    Are you using absolute positioning? (bad)
     
  3. Glenn

    Glenn Member

    Messages:
    202
    margin-left:auto; margin-right:auto;
     
  4. Phreaddee

    Phreaddee Super Moderator Staff Member

    Messages:
    1,978
    Your missing my point
    Doesnt center in ie.
    6?7?8?9?
    They each have their own unique quirks.
    Which reminds me, does it have a doctype?
     
  5. Glenn

    Glenn Member

    Messages:
    202
    Ok, I guess my question is, how do I get it centered in IE?

    No doctype
     
  6. Phreaddee

    Phreaddee Super Moderator Staff Member

    Messages:
    1,978
    I know what your question is.

    Give it a doctype and WHAT VERSION OF IE!!
     
  7. d a v e

    d a v e New Member

    Messages:
    671
    it's probably MS IE :)

    p.s. glenn a link to the site is often easiest ;)
     
  8. Glenn

    Glenn Member

    Messages:
    202
    It's all versions it seems.

    Right now I have it temporarily fixed with a table.
     
  9. d a v e

    d a v e New Member

    Messages:
    671
    need a link to the page or the whole code. preferably a link
     
  10. RKdesigns

    RKdesigns New Member

    Messages:
    8
    Probably obvious, but had you had a width specified in the CSS for the object you are trying to center? If no specific width is set, it may make the margin attributes a little wonky. Just a suggestion.
     
  11. RKdesigns

    RKdesigns New Member

    Messages:
    8
    Never mind, as I just checked a project I am working on in IE 7, 8, and 9 to find out that I am having the same issue.
     
  12. Janja

    Janja New Member

    Messages:
    65
    I have found in IE that sometimes you have to use text-align:center for the body for it to center.
    On your container use: width:960px; margin: 0 auto; text-align:left

    Hope that solves your problem.
     
  13. Phreaddee

    Phreaddee Super Moderator Staff Member

    Messages:
    1,978
    Funny, this seems like such a common problem, but its never happened to me.

    Add a doctype
    Add a reset
    Keep your code simple and streamlined.
    Dont use absolute positioning
    And this should never be a problem...
     

Share This Page