Bootstrap 3 Carousel没有滑动

时间:2014-09-24 10:15:27

标签: javascript jquery twitter-bootstrap-3 carousel

所以我有滑动的问题。 它只是不会滑动! 图片更像是互相盘旋或褪色,但不会有任何滑动。

有没有人知道这是怎么来的,我做错了什么? 这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>and</title>

    <!-- Bootstrap CSS -->
    <link href="stylesheets/bootstrap.css" rel="stylesheet">

</head>
<body>

<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>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
        <div class="item active">
            <img src="images/Slider/Earth_slider.png" alt="...">
            <div class="carousel-caption">
                <h2>First Slider</h2>
            </div>
        </div>
        <div class="item">
            <img src="images/Slider/Rosetta_slider.png" alt="...">
            <div class="carousel-caption">
                <h2>Second Slider</h2>
            </div>
        </div>
        <div class="item">
            <img src="images/Slider/Showreel_slider.png" alt="...">
            <div class="carousel-caption">
                <h2>Second Slider</h2>
            </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>



<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="javascript/bootstrap.min.js"></script>
<script src="javascript/jquery.min.js"></script>

<script>
    $('.carousel').carousel({
        interval: 1000
    })​;
</script>



</body>
</html>

3 个答案:

答案 0 :(得分:1)

您的基本Bootstrap.js没有Carousel组件。

使用Bootstrap.js安装Carousel.js/.css,否则,您需要单独向网页添加Carousel.js

您可以在此处选择所需的捆绑: http://getbootstrap.com/customize/

答案 1 :(得分:0)

你必须初始化jQuery:

<script>
    $(function() {
      $('.carousel').carousel({
        interval: 1000
      })​;
    }
</script>

或尝试使用markdown进入div

data-ride="carousel"

答案 2 :(得分:0)

您需要在脚本中调用carousel.js。您还需要定义您的Javascript,如

<script>
$(function() {
  $('.carousel').carousel({
    interval: 2000
  });
});

Here是你可以尝试的小提琴。