旋转木马不起作用

时间:2017-11-29 23:35:42

标签: jquery twitter-bootstrap

我找不到自己的错误。有人可以帮助我解释为什么我的旋转木马不工作?

这是头部:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="css/main.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="top-block">
  <div class="container">
    <div class="row">
      <div class="col-md-6 ">
        <div id="carousel-id" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-target="#carousel-id" data-slide-to="0" class=""></li>
            <li data-target="#carousel-id" data-slide-to="1" class=""></li>
            <li data-target="#carousel-id" data-slide-to="2" class=""></li>
            <li data-target="#carousel-id" data-slide-to="3" class="active"></li>
          </ol>
          <div class="carousel-inner">
            <div class="item">
              <img src="http://www.gettyimages.com/gi-resources/images/VR/GettyImages-500977426.jpg">
              <div class="container">
              </div>
            </div>

            <div class="item">
              <img src="img/slider1.png">
              <div class="container">
              </div>
            </div>
            <div class="item">
              <img src="http://www.gettyimages.com/gi-resources/images/Embed/new/embed2.jpg">
              <div class="container">
              </div>
            </div>

            <div class="item active">
              <img src="https://www.w3schools.com/w3css/img_fjords.jpg">
              <div class="container">
              </div>
            </div>
            <a class="left carousel-control" href="#carousel-id" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
            <a class="right carousel-control" href="#carousel-id" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

当我点击它们并且没有滑动到另一张图片时,控制器不工作。

1 个答案:

答案 0 :(得分:1)

您忘记导入Bootstrap JS CDN

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

&#13;
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="css/main.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div class="top-block">
  <div class="container">
    <div class="row">
      <div class="col-md-6 ">
        <div id="carousel-id" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-target="#carousel-id" data-slide-to="0" class=""></li>
            <li data-target="#carousel-id" data-slide-to="1" class=""></li>
            <li data-target="#carousel-id" data-slide-to="2" class=""></li>
            <li data-target="#carousel-id" data-slide-to="3" class="active"></li>
          </ol>
          <div class="carousel-inner">
            <div class="item">
              <img src="http://www.gettyimages.com/gi-resources/images/VR/GettyImages-500977426.jpg">
              <div class="container">
              </div>
            </div>

            <div class="item">
              <img src="img/slider1.png">
              <div class="container">
              </div>
            </div>
            <div class="item">
              <img src="http://www.gettyimages.com/gi-resources/images/Embed/new/embed2.jpg">
              <div class="container">
              </div>
            </div>

            <div class="item active">
              <img src="https://www.w3schools.com/w3css/img_fjords.jpg">
              <div class="container">
              </div>
            </div>
            <a class="left carousel-control" href="#carousel-id" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
            <a class="right carousel-control" href="#carousel-id" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;