【发布时间】:2020-11-18 03:28:40
【问题描述】:
我试图将两张图片并排作为背景,并带有一些文字。一旦我开始定位文本,整个浏览器就会开始向右扩展。我想只使用要定位的文本进行操作。谢谢你的帮助。
.container1{
background-image: url(pictures/1.png),url(pictures/2.jpg);
background-repeat: no-repeat;
width: 100%;
height: 600px;
background-position: left 0px,right 0px;
background-size: 50% auto,50% auto;
}
.cityText{
position: relative;
top: 50%;
left: 80%;
}
<div class="container1">
<div class="cityText">
<q>
Life is what happens <br>
when you’re busy<br>
making other plans.</q>
<p>-John Lennon-</p>
</div>
<div class="beautyText">
<q>
People are like stained - glass windows.<br>
They sparkle and shine when the sun is out,<br>
but when the darkness sets in, their true beauty<br>
is only if there is a light from within.
</q>
<p>-Elisabeth Kubler-Ross-</p>
</div>
</div>
【问题讨论】:
-
将
position: absolute;添加到cityText可以解决您的问题吗? -
这能回答你的问题吗? Positioning text over image (html,css)
-
是的。谢谢