Bootstrap 我的引导旋转木马不工作

dldeef67  于 12个月前  发布在  Bootstrap
关注(0)|答案(3)|浏览(117)

我尝试了引导旋转木马,但它就是不工作。我做了大量的研究,并检查了一遍又一遍,但它仍然不工作。有人能告诉我为什么吗?(我刚刚开始,所以一些详细的解释将非常感谢tq)
这是我的代码。

<div class="container-fluid">
    <div class="carousel slide" data-ride="carousel" id="carousel">
        <ol class="carousel-indicators">
            <li data-target="#carousel" data-slide to="0" class="active"></li>
            <li data-target="#carousel" data-slide to="1"></li>
            <li data-target="#carousel" data-slide to="2"></li>
        </ol>
        <div class="carousel-inner">
            <div class="item active">
                <img src="https://f1.media.brightcove.com/8/4495439099001/4495439099001_5325814229001_5305215728001-vs.jpg?pubId=4495439099001&videoId=5305215728001">
            </div>
            <div class="item">
                <img src="http://www.asianews.it/files/img/INDIA_-_0907_-_Vescovo_di_Vasai_su_MT.jpg">
            </div>
            <div class="item">
                <img src="https://www.crossroadsinitiative.com/wp-content/uploads/2016/02/Mother-Teresa-of-Calcutta-Mother-Teresas-National-Prayer-Breakfast-Message.jpg">
            </div>
        </div>
        <a class="carousel-control left" href="#carousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="carousel-control right" href="#carousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div>
</div>

字符串

juud5qan

juud5qan1#

添加Bootstrap&jQueryCDN后,
你的旋转木马似乎工作正常,
你必须检查其中之一:

  • 添加jQuery引用,如果你没有。
  • 如果你已经有了jQuery,请确保它在引导JavaScript之前。
  • 如果下载了bootstrap和jQuery,并且您在本地拥有它们,请确保您使用的是指向文档的正确链接。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="container-fluid">
    <div class="carousel slide" data-ride="carousel" id="carousel">
        <ol class="carousel-indicators">
            <li data-target="#carousel" data-slide to="0" class="active"></li>
            <li data-target="#carousel" data-slide to="1"></li>
            <li data-target="#carousel" data-slide to="2"></li>
        </ol>
        <div class="carousel-inner">
            <div class="item active">
                <img src="https://f1.media.brightcove.com/8/4495439099001/4495439099001_5325814229001_5305215728001-vs.jpg?pubId=4495439099001&videoId=5305215728001">
            </div>
            <div class="item">
                <img src="http://www.asianews.it/files/img/INDIA_-_0907_-_Vescovo_di_Vasai_su_MT.jpg">
            </div>
            <div class="item">
                <img src="https://www.crossroadsinitiative.com/wp-content/uploads/2016/02/Mother-Teresa-of-Calcutta-Mother-Teresas-National-Prayer-Breakfast-Message.jpg">
            </div>
        </div>
        <a class="carousel-control left" href="#carousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="carousel-control right" href="#carousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div>
</div>

字符串

ctzwtxfj

ctzwtxfj2#

尝试发布可以运行的完整代码,以便我们可以直接在那里编辑。以下是输出。您没有导入库

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
  <div class="carousel slide" data-ride="carousel" id="carousel">

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

     <div class="carousel-inner">
       <div class="item active">
         <img src="https://f1.media.brightcove.com/8/4495439099001/4495439099001_5325814229001_5305215728001-vs.jpg?pubId=4495439099001&videoId=5305215728001">
       </div>
       <div class="item">
         <img src="http://www.asianews.it/files/img/INDIA_-_0907_-_Vescovo_di_Vasai_su_MT.jpg">
       </div>
       <div class="item">
         <img src="https://www.crossroadsinitiative.com/wp-content/uploads/2016/02/Mother-Teresa-of-Calcutta-Mother-Teresas-National-Prayer-Breakfast-Message.jpg">
       </div>
    </div>

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

  </div> 
</div>

</body>
</html>

字符串

chy5wohz

chy5wohz3#

兄弟我正面临着同样的问题,我并没有真正找到解决方案,在许多教程,所以我决定重新开始,把原始引导启动器模板,然后它为我工作得很好。
下面是模板的链接:https://getbootstrap.com/docs/4.0/getting-started/introduction/
希望对你有帮助:)

相关问题