1

我有以下 HTML:

<div id="container">
    <div id="header"><h1>Sed sollicitudin dignissim justo, sed.</h1></div>
</div>

和以下CSS:

div#container
{
    text-align:left;
    width:500px;
    margin:0 auto;
}

这将创建一个container跨越整个屏幕的 div 和header第一个 div 中的另一个 div container,其中第二个 div 具有固定宽度并以第一个 div 为中心。

这在 IE6 中运行良好,但在 IE5.x 中,它似乎没有居中,它与屏幕左侧对齐。

如何在 IE5.x 中居中?

4

2 回答 2

7

IE 5.x 使块居中,就好像有内联元素一样。

#containers_parent { text-align: center; }
#container { text-align: left; } /* To reset the alignment for the text inside */
于 2012-09-02T11:37:24.010 回答
0

如果您在页面上只有#container,只需<center>在顶部添加

于 2012-09-02T11:47:21.750 回答