是否可以在所有断点中显示响应式Boostrap轮播?

时间:2015-06-03 13:09:30

标签: html twitter-bootstrap carousel

我希望在大屏幕(lg和md)中连续显示10张幻灯片,并根据断点大小,轮播必须显示幻灯片(在移动视图1幻灯片和平板电脑视图中3或4张幻灯片基于屏幕尺寸)。是否可以在所有断点处设计响应式引导程序轮播?

1 个答案:

答案 0 :(得分:0)

Carousel doc:

您可以使用xs-hidden类根据屏幕创建和隐藏内容,以隐藏小屏幕上的任何内容。

<div id="carousel-top" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="hidden carousel-indicators" style="display:none">
  <li data-target="#carousel-top" data-slide-to="0" class="active"></li>
  <li class="" data-target="#carousel-top" data-slide-to="1"></li>
  <li class="" data-target="#carousel-top" data-slide-to="2"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">

  <div class="item active">
  <img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="...">
</div>

<div class="item  hide-on-mobile">
  <img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="...">
</div>

<div class="item">
  <img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="...">
</div>

<div class="item keep-me-out-of-small-screen">
  <img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="...">
</div>

<div class="item">
  <img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="...">
</div>


</div>

<!-- Controls -->
<a class=" left carousel-control" href="#carousel-top" role="button" data-slide="prev">
  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  <span class="sr-only">Previous</span>
</a>
<a class=" right carousel-control" href="#carousel-top" role="button" data-slide="next">
  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  <span class="sr-only">Next</span>
</a>

JQuery:

if ($(window).width() < 960) {
     $('#carousel-top .keep-me-out-of-small-screen').removeClass('item').addClass('hide');
}