<分区>
<分区>
我试图将 div 置于一个外部 div 的中心,但我做不到。
我的 html 是这样的:
<div class="outterDiv">
<div class="innerDivBig">
<div style="width: 180px; float:left;margin-right: 5px;background-color: yellow;">
Inner Div
</div>
<div style="width: 180px; float:left;margin-right: 5px;background-color: yellow;">
Inner Div
</div>
<div style="width: 180px; float:left;margin-right: 5px;background-color: yellow;">
Inner Div
</div>
<div style="clear:both"/>
</div>
</div>
我的 CSS 是这样的:
.outterDiv{
width: 600px;
border: 1px solid #f00;
text-align: center;
}
.innerDivBig{
margin: 0 auto;
display:table;
}
这里是 jsfiddle
.
最佳答案
.outterDiv{
width: 600px;
border: 1px solid #f00;
text-align:center;
}
.innerDivBig{
display: inline-block;
}
关于html - 如何在另一个div中水平居中div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38656712/