【问题标题】:Twitter Bootstrap Carousel - How to implement a continuous slow scroll?Twitter Bootstrap Carousel - 如何实现连续慢滚动?
【发布时间】:2014-11-06 10:03:18
【问题描述】:

我正在使用 Twitter Bootstrap 3,并且有一个包含 8 张图片的轮播。它显示 4,然后跳转到下一个 4。此时,必须使用左右箭头按钮(或稍等片刻)才能更改轮播。我怎样才能让它在轮播中的项目中有一个连续的、缓慢的滚动?我不希望它从 4 组跳到下一组,我想要一个连续滚动。

【问题讨论】:

  • 在该示例中,轮播向左滚动一段时间,然后开始从左侧返回 - 我希望它从左向右移动。

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


【解决方案1】:

您需要做的第一件事是将以下代码复制并粘贴到您的 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 });
});

【讨论】:

  • 感谢您的回复。不,不完全是我需要的。我需要轮播才能连续滚动。基本上,当轮播变为新项目时​​,我不希望暂停。
猜你喜欢
  • 2012-03-04
  • 2018-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-15
  • 2021-04-07
  • 2012-11-11
  • 2020-12-15
相关资源
最近更新 更多