我无法让我的网站以CSS为中心。我已经尝试了所有的网络,包括各地提出的常用方法:无法获得CSS元素居中
body {
text-align: center;
}
#container {
width: 770px;
margin: 0 auto;
text-align: left;
}
然后使用
<div id="container>
<!-- Centered Content Goes here-->
</div>
,但它只是不会去市中心。它停留在页面的左侧。
的CSS的,我想为中心元素的一个例子是这样的:
#topHeader
{
background:url(images/top_header.jpg);
position:absolute;
width: 695px;
height: 242px;
top: 0px;
left: 0px;
}
所以,我的HTML应该是这样的:
<div id="container>
<div id="topHeader></div>
<!-- All other elements go here as well-->
</div>
但正如我之前提到的,该元素保持放置。 谢谢! 埃里克
深红色,你不能在不知道其宽度的情况下居中块元素。 –