我需要几行文本在图像上水平和垂直居中,我在互联网上阅读了很多,但我没有帮助我任何解决方案。
HTML:
<div id="textContainer">
Preparing for important meeting? <br />
<b>Drink some coffeee!</b> <br />
<img src="http://i.imgur.com/me2octq.jpg" />
</div>
<div id="baner">
<div class="imgBaner"></div>
</div>
CSS:
.imgBaner {
margin: 0 auto;
width: 100%;
height: 460px;
background: url(http://i.imgur.com/5pijCrS.jpg) no-repeat center;
position: relative;
}
#textContainer {
position: absolute;
font-size: 32px;
text-align: center;
z-index: 1;
color: yellow;
}
我也附上了小提琴:http: //jsfiddle.net/vXzKc/
我感谢每一个帮助!