我有一个图像和文本在一个div中彼此相邻。我试图在中间垂直对齐文本,但它仍然在顶部。请帮助!
http://jsfiddle.net/9KDva/
超文本标记语言:
<div class="title-block">
<div class="img-holder"><img width="101" height="104" src="http://www.test.com/test.jpeg" /></div>
<div class="title">Get Your Nose Out of Your IPhone</div>
</div>
字符串
CSS:
.title-block {
width:272px;
height: 110px;
vertical-align:middle;
}
.img-holder {
float: left;
margin: 0 6px 0 0;
position: relative;
}
.img-holder img {
display: block;
}
.title {
display:block;
text-transform: uppercase;
margin: 8px 0 9px;
}
型
3条答案
按热度按时间icomxhvb1#
您可以使用
table
和table-cell
:并将您的class='title'
移动到img-holder
中Fiddle
在
image
-fiddle中保留填充字符串
46scxncf2#
我把你的div改成了span,让
vertical-align: middle
可以工作。参见小提琴:http://jsfiddle.net/9KDva/4/
CSS:
字符串
超文本标记语言:
型
nkoocmlb3#
使用vertical-align:middle在div上不起作用。
这样的东西可能会起作用:
字符串