我正在尝试让一个表格单元格在页面中居中,而且通常的策略都没有奏效;我已经尝试过,特别是文本对齐和边距的不同方法:auto,都没有运气。
有谁知道我哪里出错了?这是我的代码:
<div class="table col-xs-12" style="margin-top: 20px; width: 100%; ">
<h3 class="text-center col-xs-12" style="margin-top: 200px; color: #dcdcdc; background-color: #333333; height: 30px; vertical-align: middle; display: table-cell; ">
Your account is currently pending. Please check back in again later.
</h3>
</div>
提前感谢您的帮助!
编辑:如果有帮助的话,这是一个fiddle。
答案 0 :(得分:1)
从<div id="div1">5% height</div>
<div id="div2">95% height</div>
课程中删除position: absolute;
,删除包装器div并将.centered
直接应用于.centered
类的div。
HTML:
.table
CSS:
<div class="table col-xs-12 centered" style="margin-top: 20px; ">
<h3 class="text-center col-xs-12" style="margin-top: 200px; color: #dcdcdc; background-color: #333333; height: 30px; width: 100% !important; vertical-align: middle; display: table-cell; ">Your account is currently pending. Please check back in again later.</h3>
</div>