【发布时间】:2012-03-04 04:42:19
【问题描述】:
下面的代码(也可作为a demo on JS Fiddle 使用)不会将文本放置在中间,正如我所希望的那样。即使使用margin-top 属性,我也找不到任何方法将div 中的文本垂直居中。我该怎么做?
<div id="column-content">
<img src="http://i.stack.imgur.com/12qzO.png">
<strong>1234</strong>
yet another text content that should be centered vertically
</div>
#column-content {
display: inline-block;
border: 1px solid red;
position:relative;
}
#column-content strong {
color: #592102;
font-size: 18px;
}
img {
margin-top:-7px;
vertical-align: middle;
}
【问题讨论】: