【发布时间】:2014-04-18 21:10:35
【问题描述】:
我正在尝试列出一些图像,并且对于每个图像我想要一个标题,以及一些细节,比如说标题,现在的问题是标题的宽度是相对于父 div是正常的,但我希望它与图像宽度相关,但由于我在 img 上有 img-responsive 类,我不知道如何实现这一点。也许你们可以帮帮我。
这是一个活生生的例子:http://jsbin.com/cudugize/1/edit?html,css,output
这里是代码
HTML
<div class="col-sm-3 col-xs-6 col-md-2 col-lg-3">
<div class="thumbnail">
<a href="url"><img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="..."></a>
<div class="caption img-responsive">
<h4 class="text-center"><a href="url" title="title" class="homepage anchorhead text-uppercase">Nice title</a></h4>
<p class="text-center"><a href="#" class="homepage city text-uppercase"><span class="glyphicon glyphicon-globe"></span> usa</a></p>
</div>
</div>
<div class="thumbnail">
<a href="url"><img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="..."></a>
<div class="caption img-responsive">
<h4 class="text-center"><a href="url" title="title" class="homepage anchorhead text-uppercase">Nice title</a></h4>
<p class="text-center"><a href="#" class="homepage city text-uppercase"><span class="glyphicon glyphicon-globe"></span> usa</a></p>
</div>
</div>
</div>
CSS
Aditional bootstrap core css
.thumbnail{
position: relative;
width: 100%;
border: none !important;
}
.thumbnail .caption{
position: absolute;
bottom: 0px;
background: rgba(0,0,0,0.50);
width: 100%;
padding: 0px !important;
}
【问题讨论】:
标签: html css twitter-bootstrap-3