我想将<div>
放置到另一个中,并希望居中。 我的方法是这样的:div在另一个中间
<div id="redthing">
<div id="whitebox" >
</div>
</div>
名为.css - 代码如下:
#redthing {
margin-top: 2px;
background-color: #f00d28;
height: 250px;
}
#whitebox {
margin: 0 auto;
margin-top: 10px;
padding-top: 20px;
height: 10px;
width: 400px;
background-color: white;
border:5px solid #000;
}
就像你所看到的,空白和边距不工作,使其中心在页面的中间(这意味着存在whitebox
和顶部和redbox
的底部之间的同一个地方。 请帮
见http://stackoverflow.com/questions/396145/whats-the-best- way-of-centering-a-div-vertical-with-css – 2012-07-22 17:10:00