[英]Bootstrap caption goes past image
<div class="container">
<style>
.spacer {
margin-top: 2%;
margin-bottom: 2%;
}
.clear-L-R {
padding-left:0px;
padding-right: 0px;
}
.caption{
cursor: pointer;
position: absolute;
top:0;
height:100%;
background-color: rgba(0,0,0,0.65);
opacity: 0;
-webkit-transition:all 0.45s ease-in-out;
-moz-transition:all 0.45s ease-in-out;
-o-transition:all 0.45s ease-in-out;
-ms-transition:all 0.45s ease-in-out;
transition:all 0.45s ease-in-out;
}
.caption:hover{
opacity: 1;
}
.caption-text h1{
text-transform: uppercase;
font-size: 24px;
}
.caption-text{
color: #fff;
text-align: center;
}
</style>
<div class="container col-lg-12 spacer"></div>
<div class="container col-lg-12">
<div class="row-fluid">
<div class="col-sm-12 col-lg-6">
<img src="http://lorempixel.com/800/600/nature" class="img-responsive" alt="">
<div class="col-xs-12 caption caption-text">
<h1>Amazing Caption</h1>
<p>Whatever It Is - Always Awesome</p>
</div>
</div>
<div class="col-sm-12 col-lg-6">
<img src="http://lorempixel.com/800/600/nature" class="img-responsive" alt="">
<div class="col-xs-12 caption caption-text">
<h1>Amazing Caption</h1>
<p>Whatever It Is - Always Awesome</p>
</div>
</div>
</div>
</div><!--END row-->
I am trying to make the caption responsive and only fill the width of the image, but it is taking about the size of the padding. 我正在尝试使标题具有响应性,并且仅填充图像的宽度,但是它占用了填充的大小。 Tried a few fixes nothing seems to work.
尝试了一些修复程序似乎没有任何作用。 The gray part is where the caption goes over.
灰色部分是标题结束的地方。
Your caption is absolutely positioned relative to the col-sm-12 col-lg-6
div
, which has padding on the left and right. 您的标题绝对相对于
col-sm-12 col-lg-6
div
,左右两侧都有填充。 One option to get the display you are looking for is to put the caption into a separate relatively positioned div
. 获得所需显示内容的一种方法是将标题放入相对位置相对独立的
div
。 See this bootply which gives an example. 请参阅此示例 ,它提供了示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.