我有一個圖像和文本在div中彼此相鄰。我試圖在中間垂直對齊文本,但它保持在最上面。請幫忙!垂直對齊塊元素
HTML:
<div class="title-block">
<div class="img-holder"><img width="101" height="104" src="http://www.girlsguidetomanners.com/wp-content/uploads/2014/02/url-16-101x104.jpeg" class="attachment-homepoststhumbnail wp-post-image" alt="url-16" /></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;
}
[CSS垂直對齊:中間不工作]的可能重複(http://stackoverflow.com/questions/16629561/css-vertical-align-middle-not-working) – steveax
此鏈接將有助於理解垂直對齊http://www.impressivewebs.com/difference-block-inline-css/ – ejaenv