How to vertically align text on top of an absolutely positioned div
This question already has an answer here:
If you feel like tweaking around, I think the quickest for you is to take out your calculator and set the top attribute at the negative of the half of your image's height.
For example : if your image has an height of 300px, then :
.text{
position : absolute;
top : -150px;
}
Be careful, you can't use vertical-align:middle
everywhere, there are plenty of links about this, you should check this : Centering in the Unknown.
Good luck!
链接地址: http://www.djcxy.com/p/41506.html上一篇: 如何垂直居中对齐具有背景图像的div
下一篇: 如何在绝对定位的div上垂直对齐文本