如何在圖像上垂直居中文字?我已經對它的外觀做了一個設置,但是由於它們有不同的高度,所以我無法讓文字集中在每張圖片上。如何垂直居中文字重疊圖像?
我已經嘗試使用其他問題中提到的「top」屬性和垂直對齊方法,但似乎沒有任何工作適用於這種情況。
反正有這個可以實現嗎?
的的jsfiddle可以在這裏找到:http://jsfiddle.net/Sf3RX/2/
HTML
<div class="column">
<div class="image">
<img src="/">
<p class="info">cats
<br><span>#Photography</span>
</p>
</div>
CSS
.image {
position: relative;
width: 25%;
text-align: center;
}
img {
width: 100%;
}
p.info {
position: absolute;
width: 100%;
z-index: 10;
top: 25%;
}
是圖像大小的動態,或者你能解決這個問題? – dsfg