我很难在带有引导的旋转木马上实现响应边界。
我的处境很简单。我不想要全幅旋转木马,我的图像是940px宽,必须是宽度的最大尺寸。当然,旋转木马必须与中心水平对齐。
这就是为什么我用下面的CSS将所有东西包装在旋转木马容器中的原因:
#carousel-container {
margin: 25px auto 0px auto;
max-width: 940px;
}
这是我当前的HTML代码(bluebg类只是在行中添加了一个蓝色背景)。非常像引导文档中给出的标准代码:
<div class="row bluebg">
<div id="carousel-container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="img/carousel-test.jpg" alt="Carousel Test">
</div>
<div class="item">
<img src="img/carousel-test.jpg" alt="Carousel Test 2">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
一切看起来都很好,但事情是。。。我需要在顶部、左侧和右侧添加边框。10px白色边框。我什么都试过了,但每次我调整浏览器窗口的大小时,左右边框都会被剪切,不包含在响应视图中。
现在,我在这里添加了CSS边框:
.carousel-inner {
border-top: 10px;
border-left: 10px;
border-right: 10px;
border-bottom: 00px;
border-color: #fff;
border-style: solid;
}
我也试过同样的方法,即使是在旋转木马课上,但没有成功。
这是我从桌面浏览器中得到的:
这是我从移动视图或将浏览器窗口大小调整到最小值得到的:
我希望那些边界总是显示出来!
我怎样才能做到这一点?提前谢谢你们。
最佳答案
必须重写设置为0边框的媒体查询。
从inpector搜索执行此操作的选择器和媒体查询,例如:
@media screen and (max-width: 979px) {
div.corousel-inner {
border: 0;
}
}
在您的
carousel-inner
中添加一个类,如下所示在CSS文件中添加以下规则:
@media screen and (max-width: 979px) {
div.corousel-inner.my-inner {
border-top: 10px;
border-left: 10px;
border-right: 10px;
border-bottom: 00px;
border-color: #fff;
border-style: solid;
}
}
关于jquery - 向Bootstrap轮播添加响应边界,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26255740/