Bootstrap Carousal在我的代码中不起作用

时间:2020-05-31 16:47:38

标签: html css twitter-bootstrap gallery

这些天我正在学习引导程序。我正在开发主页。但是旋转木马没有用。请检查代码,并告诉我代码中缺少的内容。我只是从w3school复制粘贴轮播代码。我不知道我在哪里。如果有人可以在这方面帮助我,那就太好了。

    <!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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">

  </head>
  <body>

   <!-- Image and text -->
<nav class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="#">
    <img src="Solupo_h.png" width="500" height="180" class="d-inline-block align-top" id="header" alt="top header" loading="lazy" >
    </a>
</nav>

<div id="ct">
  <div class="corner "id="left_top"></div>
  <div class="corner" id="left_bottom"></div>
  <div class="corner" id="right_top"></div>
  <div class="corner" id="right_bottom"></div>
  <span>Winston Churchill</span>
  <blockquote>
    <p><i>&ldquo;Success consists of going from failure to failure without loss of enthusiasm.&rdquo; </i></p>
  </blockquote>
</div>

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

    <!-- Indicators -->
    <ul class="carousel-indicators">
      <li data-target="#demo" data-slide-to="0" class="active"></li>
      <li data-target="#demo" data-slide-to="1"></li>
      <li data-target="#demo" data-slide-to="2"></li>
    </ul>

    <!-- The slideshow -->
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img src="654-500x3002.jpg" alt="Los Angeles">
      </div>
      <div class="carousel-item">
        <img src="654-500x3002.jpg" alt="Chicago">
      </div>
      <div class="carousel-item">
        <img src="654-500x3002.jpg" alt="New York">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="carousel-control-prev" href="#demo" data-slide="prev">
      <span class="carousel-control-prev-icon"></span>
    </a>
    <a class="carousel-control-next" href="#demo" data-slide="next">
      <span class="carousel-control-next-icon"></span>
    </a>

  </div>
</div>



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

1 个答案:

答案 0 :(得分:0)

您可能尚未下载引导程序样式表或javascript资产。该代码很好,因为您提到您直接从w3schools复制并粘贴了代码。

您需要下载以下文件并将其添加到您的文件夹中:

css / bootstrap.min.css js / bootstrap.min.js

OR

您可以将以下内容粘贴到.get(index)标记中:

$()

您可以在<head>标签的末尾添加以下内容:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

希望有帮助!