为什么我的bootstrap 3.7轮播不起作用?

时间:2017-04-18 22:23:55

标签: javascript jquery css twitter-bootstrap-3

我一直在关注如何实现bootstrap的这个功能的指南,对于我的生活,我无法弄清楚它为什么不起作用。我在标题中链接了所有CDN,并且链接了Js脚本。所有这些都直接从bootstrap网站复制。

<div id="productCarousel" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#productCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#productCarousel" data-slide-to="1"></li>
        <li data-target="#productCarousel" data-slide-to="2"></li>
        <li data-target="#productCarousel" data-slide-to="3"></li>
    </ol>

    <div class="carousel-inner" role="listbox">
        <div class="item active">
            <img src="../../static/images/city.jpg">
        </div>
        <div class="item">
            <img src="../../static/images/city.jpg">
        </div>
        <div class="item">
            <img src="../../static/images/city.jpg">
        </div>
        <div class="item">
            <img src="../../static/images/city.jpg">
        </div>
    </div>
    <a class="left carousel-control" href="#productCarousel" 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="#productCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>

1 个答案:

答案 0 :(得分:2)

我检查了你的代码,一切正常。

检查嵌入库的方式。

  1. Boostrap CSS
  2. 的jQuery
  3. Bootstrap JS
  4. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    
    <div id="productCarousel" class="carousel slide" data-ride="carousel">
                        <ol class="carousel-indicators">
                            <li data-target="#productCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#productCarousel" data-slide-to="1"></li>
                            <li data-target="#productCarousel" data-slide-to="2"></li>
                            <li data-target="#productCarousel" data-slide-to="3"></li>
                        </ol>
    
                        <div class="carousel-inner" role="listbox">
                            <div class="item active">
                                <img src="http://placehold.it/800x400">
                            </div>
                            <div class="item">
                                <img src="http://placehold.it/800x400">
                            </div>
                            <div class="item">
                                <img src="http://placehold.it/800x400">
                            </div>
                            <div class="item">
                                <img src="http://placehold.it/800x400">
                            </div>
                        </div>
                        <a class="left carousel-control" href="#productCarousel" 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="#productCarousel" role="button" data-slide="next">
                            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                    </div>