【问题标题】:Bootstrap carousel ignoring data-interval attribute引导轮播忽略数据间隔属性
【发布时间】:2015-12-02 18:06:18
【问题描述】:

这是我的标记:

<div id="carousel-example-generic" class="carousel slide" data-interval="false" data-pause="hover">
        <!-- Indicators -->
        <ol class="carousel-indicators">
            <li data-target="#carousel-example-generic" data-slide-to="0"></li>
            <li data-target="#carousel-example-generic" data-slide-to="1"></li>
            <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
            <div class="item active">
                <div style="height:200px;">Slide 1</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item">
                <div style="height:200px;">Slide 2</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item ">
                <div style="height:200px;">Slide 3</div>
                <div class="carousel-caption">
                    ...
                </div>
            </div>
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div>

我使用的是 bootstrap v3.0.3,但页面加载后轮播仍然开始滚动。我也试过包括:

$(function () {
    $(".carousel").carousel({ interval: false });
});

我在有和没有data-interval 属性的情况下都这样做了,但都无济于事。加载页面后,轮播会自动开始滚动。我看到了其他关于此的问题,但他们都指的是旧版本,并暗示它现在已经修复。

有什么想法吗?

【问题讨论】:

  • 似乎在 3.0.3 上运行良好 - bootply.com/103352 同一页面上还有其他 JavaScript 代码或其他轮播吗?
  • 你完全正确!在我的脚本之前引用了一些其他插件的脚本。它们是我前段时间建立的另一个网站的剩余物。复制粘贴的危险!它工作得很好,谢谢:)这里的常见做法是什么?我不能投票你的评论作为答案。我要删除这个问题吗?
  • 我将我的评论添加为解决方案/答案。请接受,以便其他人知道您的问题已解决。谢谢!

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


【解决方案1】:

您的轮播标记对于 3.0.3 (http://bootply.com/103352) 是正确的

确保同一页面上没有其他 JavaScript 代码或其他轮播。

【讨论】:

    猜你喜欢
    • 2019-05-07
    • 2014-12-31
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-04
    相关资源
    最近更新 更多