treehouse : what would you like to learn today?
Web Design Web Development iOS Development

IE 7 Centering

  • trying to center my page layout in IE 7.

    works fine in Safari, Firefox, Opera with the following :

    body {
    margin: 0 auto;
    min-width: 990px;
    width: 990px;
    background: #000000 url(../images/bg.jpg);
    background-position: 50% 0;
    background-repeat: repeat-y;
    padding:0;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 13px;
    }

    but I can't seem to get it to center properly in IE 6/7

    any ideas?

    cheers,

    zanuka
  • Add
    html { text-align:center;}


    You need that on your parent element to get margin: 0 auto; to work in IE.

    Then you need "text-align:left;" on your <body> tag to make your text align left again.

    (Although, I would not use your body as your page outline, I would make a <div ID="container"> or something similar.)