【发布时间】:2014-11-18 13:18:39
【问题描述】:
我使用 bootstrap 并在图像上覆盖标题时遇到问题,标题 div 无法放入框内,如下所示:
HTML:
<div class="col-sm-4">
<a href="#">
<img src="images/upload/projects/21/wolf.jpg" class="img-responsive" alt="" />
<div class="desc">
<p class="desc_content">The pack, the basic unit of wolf social life.</p>
</div>
</a>
</div>
<div class="col-sm-4">
<a href="#">
<img src="images/upload/projects/21/cake.png" class="img-responsive" alt="">
<div class="desc">
<p class="desc_content">The pack, the basic unit of wolf social life.</p>
</div>
</a>
</div>
CSS:
div.desc{
position: absolute;
bottom: 0px;
width: 100%;
background-color: #000;
color: #fff;
opacity: 0.5;
filter: alpha(opacity=50);
}
解决方案:
感谢@himanshu 解决了这个问题。
div.desc{
background-color: #000;
bottom: 0;
color: #fff;
left: 0;
opacity: 0.5;
position: absolute;
width: 100%;
}
.fix{
width: 100%;
padding: 0px;
}
【问题讨论】:
-
尝试使用 box-sizing:border-box;对于 p.desc_content 类
-
@Vitorino Fernandes,不走运!
-
尝试删除 width:100% 并添加 left:0;对:0;对于 div.desc
-
@Vitorino Fernandes,请查看我编辑的帖子。
-
加左:0;对:0;对于 div.desc
标签: css twitter-bootstrap-3 image-gallery