【发布时间】:2017-11-25 19:47:02
【问题描述】:
如何让这四个按钮在各自的 div 中垂直和水平居中?
更新:请不要使用 Flexbox。我没有那种奢侈。
#outer {
width: 400px;
height: 200px;
background-color: black;
display: table-cell;
}
#innerOne {
width: 400px;
height: 100px;
background-color: red;
vertical-align: middle;
}
#innerOne {
width: 400px;
height: 100px;
background-color: blue;
vertical-align: middle;
}
<div id="outer">
<div id="innerOne">
<button>One</button>
<button>Two</button>
</div>
<div id="innerTwo">
<button>Three</button>
<button>Four</button>
</div>
</div>
我希望“一”、“二”在蓝色 div 中垂直和水平居中。黑色 div 中的“三”和“四”也是如此。
我尝试了许多不同的选项,将它们的显示设置为表格和表格单元格,但没有达到我想要的效果。
【问题讨论】:
标签: css