如何在100%宽的div上保留文本?

时间:2013-11-28 10:03:26

标签: css html

所以我在页面上设置了一个100%宽度的标题,我想在横幅上放置文字并保持原位,但是当我放大和缩小文本的位置时会发生变化。如何制作文本以便文本保留在我设置的位置并放大和缩小不影响它?

小提琴jsfiddle.net/5ASJv/

html

<div id="wrap">
<div class="right">
   Hey <br />
    What is up <br />
</div></div>

css

* {
margin: 0 auto;
}

#wrap {
height: 150px;
width: 100%;
background: url(http://froggyadventures.com/wp-content/uploads/galleries/post-93/full/placeholder%20-%20Copy%20(2).gif) no-repeat center;
text-align: center;
background-color: #FFF;
}
.right{
width: 400px;
height: 110px;
position: relative;
z-index: 999;
top: 100px;
left: 100px;
}

1 个答案:

答案 0 :(得分:0)

试试这个:

* {
margin: 0 auto;
}

#wrap {
height: 150px;
width: 100%;
background: url(http://froggyadventures.com/wp-content/uploads/galleries/post-93/full/placeholder%20-%20Copy%20(2).gif) no-repeat center;
text-align: center;
background-color: #FFF;
position: relative;
}
.right{
width: 400px;
height: 110px;
position: absolute;
z-index: 999;
top: 100px;
left: 100px;
}