boostrap carousel不工作/图像只是显示在另一个上面

时间:2018-04-28 18:44:55

标签: html twitter-bootstrap-3

所以,我是新来的,自助式旋转木马不能为我工作,我直接从w3school那里拿了这个例子而它还没有工作它只显示一个图像上面的图像另一方面,不可否认,这是一项匆忙的工作,所以我可能错过了一些令人眼花缭乱的事情。更不用说我的编码知识非常不完整,我的代码:



<!DOCTYPE html>
<html lang="en">

<head>
  <title>Pagrindinis puslapis</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.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>
  <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    </button>
        <a class="navbar-brand" href="#"></a>//logotipas
      </div>
      <div class="collapse navbar-collapse" id="myNavbar">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#">Pagrindinis</a></li>
          <li><a href="#">Visos prekės</a></li>
          <li><a href="#">Populiariausios prekės</a></li>
          <li><a href="#">Nuolaidos</a></li>
          <li><a href="#">Pristatymas</a></li>
          <li><a href="#">Kontaktai</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Prisijungimas/Užsisakymas</a></li>
        </ul>
      </div>
    </div>
  </nav>

  <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="bob.jpg" alt="Los Angeles" width="1100" height="500">
      </div>
      <div class="carousel-item">
        <img src="young.jpg" alt="Chicago" width="1100" height="500">
      </div>
      <div class="carousel-item">
        <img src="thing.jpg" alt="New York" width="1100" height="500">
      </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>

  <footer class="container-fluid text-center">
    <p>Footer Text</p>
  </footer>

</body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

我认为问题出在carousel-item类上。将其替换为项目类。

答案 1 :(得分:0)

您需要将carousel-item替换为bootstrap 3 carousels的项目。

这是代码

<!-- The slideshow -->
<div class="carousel-inner">
    <div class="item active">
        <img src="http://via.placeholder.com/1100x500" alt="Los Angeles" width="1100" height="500">
    </div>
    <div class="item">
        <img src="http://via.placeholder.com/1100x500" alt="Chicago" width="1100" height="500">
    </div>
    <div class="item">
        <img src="http://via.placeholder.com/1100x500" alt="New York" width="1100" height="500">
    </div>
</div>