【发布时间】:2015-02-24 03:12:20
【问题描述】:
我在 div 中垂直对齐文本时遇到问题。我已经尝试过我在其他帖子上阅读过的建议。我确信我做错了什么很明显,但它不起作用。
<div class="banner">
<div class="span10"> <!-- bootstrap -->
<div class="banner-text">
<div class="pull-left">Here is the first line of text i want to center</div>
<div class="pull-left">Here is the second line of text i want to center</div>
<div class="clear"></div>
</div>
</div>
.banner{
margin-top:-2;
height: 70px;
background-color: #cf0000;
color: white;
height: 70px;
position: relative;
}
.banner-text{
display: block;
vertical-align: middle;
}
.pull-left {
display: block;
}
【问题讨论】:
-
vertical align文字是什么意思? - 这个 ? - jsfiddle.net/o6gqvtoo/5 -
@Paulie_D 如果我更改行高不起作用。但是是的,这就是我想要的
-
显然它确实有效,但也许您需要详细说明为什么行高不起作用...您有多行吗?
-
这并没有解释为什么需要较小的行高。也许您可以提供一张应该是什么样子的图片?
标签: html css vertical-alignment