<分区>
下面的代码(也可以作为 a demo on JS Fiddle 获得)没有将文本放在中间,正如我理想中所希望的那样。我找不到任何方法在 div
中垂直居中文本,即使使用 margin-top
属性也是如此。我该怎么做?
<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;
}