Centering div with unknown width

前端 未结 4 629
后悔当初
后悔当初 2020-12-14 15:48

i have div

which contains all page content including header footer etc.

So i would like to center this div to t

4条回答
  •  一整个雨季
    2020-12-14 16:06

    See: http://jsfiddle.net/thirtydot/rjY7F/

    HTML:

    i'm as wide as my content

    CSS:

    body {
        text-align: center;
    }
    #container {
        text-align: left;
        border: 1px solid red;
        display: inline-block;
        /* for ie6/7: */
        *display: inline;
        zoom: 1;
    }
    

提交回复
热议问题