<分区>
<分区>
Possible Duplicate:
page will not align center
我正在尝试使用 asp.net 将我的网页居中。当我使用 <center>
标记它仅使内容占位符居中。但是当我使用 CSS 属性时 margin: 0 auto
,它什么都不做。有没有办法让整个页面居中?
最佳答案
在你的 CSS 中:
body {
text-align: center;
}
#container {
width: 900px; /* or some other fixed-width value */
margin: 0 auto;
text-align: left; /* reset text-align */
}
编辑:我想我应该也显示相关标记...
...
<body>
<div id="container">
<!-- centered content here -->
</div>
</body>
...
关于asp.net - 试图让我的网页居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7585797/