html - 我想让文本覆盖在也支持响应式网站的图像中

标签 html css twitter-bootstrap-3 bootstrap-modal

以下是 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/

相关文章:

javascript - HTML5 LocalStorage重新加载文档

css - anchor 不在页面顶部,而是向下 200 像素

html - 居中两行图像

HTML 布局 : Prevent Fixed Footer from Covering Content

javascript - 缩放 div 时内容被裁剪

javascript - 仅在列表为空时更改背景

html - 如何让子 UL 脱离父 UL

javascript - onChange 按钮标签不保持其样式

html - 让图像在彼此下方排列

html - bootstrap 导航栏在 safari 浏览器中默认保持在顶部