Twitter Bootstrap Carousel - 如何实现连续慢滚动?

时间:2014-11-06 10:03:19

标签: javascript html css twitter-bootstrap twitter-bootstrap-3

我正在使用Twitter Bootstrap 3并且有一个8个图像的旋转木马。它显示4,然后跳转到下一个4.此时,必须使用左右箭头按钮(或稍等片刻)来改变旋转木马。我该如何制作,以便连续,缓慢地滚动旋转木马中的物品?我不希望它从4组跳到下一组,我想要连续滚动。

1 个答案:

答案 0 :(得分:2)

您需要做的第一件事是将以下代码复制并粘贴到HTML文件中。我们鼓励您将carousel-example-generic id更改为更独特的内容。如果这样做,请确保在整个标记中正确引用它。我们还使用了占位符图像,您需要将其替换为所需的滑块图像。

http://jsfiddle.net/2qWy8/21/

<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>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
    <li data-target="#carousel-example-generic" data-slide-to="3"></li>
    <li data-target="#carousel-example-generic" data-slide-to="4"></li>
      <li data-target="#carousel-example-generic" data-slide-to="5"></li>
      <li data-target="#carousel-example-generic" data-slide-to="6"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
         <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
              <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
                   <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
                        <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </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> <!-- Carousel -->

还有JS的解决方案,但告诉我,我会编辑我的答案,这是你需要的吗?

<强>更新 然后使用另一个小部件,而不是这个小部件

这是对插件的引用

http://www.codicode.com/demo/endless_scroll/ \

像这样使用

$(window).load(function () {
    $("#divID").endlessScroll({ width: '100%', height: '100px', steps: -2, speed: 40, mousestop: true });
});