以下是 HTML 代码。我正在使用 bootstrap 3 进行设计。我将文本放在图像上,但出现问题是因为它没有保持在正确的位置。在调整浏览器大小时,带背景的文本的位置会错位。所以请帮我解决这个问题。
<div class = "col-xs-12">
<h3 class="cen-align">STORIES OF CHANGE</h3>
<img src="img/rig_img1.jpg" class="center-block img-responsive image-wrapper" />
<p class="img-ps">Advocating Land Rights for BPL Dalit communities in Alampur village...</p>
</div>
CSS 代码:
.img-ps{
font-size:13px;
text-align:center;
position: absolute;
left:66px;
top:143px;
padding: 10px;
background-color:rgba(0,0,0,0.3);
width: 248px;
color: #FFF;
margin: 0px;
}
.image-wrapper{
position: relative;
width: 250px;
}
最佳答案
我不知道您到底需要什么,但这对您有用吗?
HTML:
<div class = "col-xs-12">
<h3 class="cen-align">STORIES OF CHANGE</h3>
<img src="img/rig_img1.jpg" class="image">
<p>Advocating Land Rights for BPL Dalit communities in Alampur village...</p>
</div>
CSS:
.image {
position: relative;
}
p {
position: absolute;
top: 200px;
left: 0;
width: 100%;
color: white;
}
关于html - 我想让文本覆盖在也支持响应式网站的图像中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36131742/