【发布时间】:2014-09-03 04:00:54
【问题描述】:
我试图将文本水平居中,但它不起作用。似乎是因为显示:table-cell 你知道解决方法吗? (请注意,我使用的是引导程序)
谢谢! > 密码笔:http://codepen.io/goodux/pen/wgBCf
html:
<div class="feature">
<span class="glyphicon glyphicon-star feature-icon"></span>
<p class="feature-text text-center">
Gather user's feedback and engineer's requirements.
</p>
</div>
css:
.feature {
margin-bottom: 3.5em;
background-color: #f3f3f3;
border-radius: 5px;
}
span.feature-icon {
background-color: #FA6900;
border-radius: 3px;
color: #FFF;
font-size: 3em;
padding: .5em;
position: absolute;
top: 0;
}
p.feature-text {
overflow: hidden;
padding: 0 .5em 0 6.5em;
vertical-align: middle;
height: 6em;
display: table-cell;
}
.text-center {
text-align: center;
}
【问题讨论】:
-
为什么要
display:table-cell? -
我希望特征文本垂直对齐。这就是我在 Stackoverflow 中找到的解决方案
标签: html css twitter-bootstrap centering