第1个回答 2013-04-26
因为你写错了 这段代码是可以居中的 <div id="container" style="position:relative;width:320px;margin:0 auto">
第2个回答 2013-04-26
我试着可以居中的,就是你的width:320,少了px。
<div id="container" style="position:relative;width:320px; height:100px;margin:0 auto; border:1px solid #0000FF"></div>
第4个回答 2015-07-10
可以设置边界老设置居中,参考如下:
<div style="height:500px; width:500px; border:1px solid #ddd; position:relative; text-align:center; margin:0 auto;">
<div style="height:200px; width:300px; background-color:#ddd; margin:-100px 0 0 -150px; position:absolute; top:50%; left:50%;"></div>
</div>本回答被网友采纳