【问题标题】:Is it possible to display responsive Boostrap carousel in all breakpoints?是否可以在所有断点中显示响应式 Bootstrap 轮播?
【发布时间】:2015-08-17 17:18:31
【问题描述】:

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

【问题讨论】:

  • 你试过什么代码?

标签: html twitter-bootstrap carousel


【解决方案1】:

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');
}

【讨论】:

    猜你喜欢
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2017-09-18
    • 2015-01-10
    • 1970-01-01
    • 2015-10-18
    • 2013-09-18
    • 2018-11-20
    相关资源
    最近更新 更多