轮播显示为单独的图像

时间:2019-03-21 17:37:28

标签: twitter-bootstrap carousel

我正在尝试使用Bootstrap制作用于销售网站的轮播,但似乎并没有启动。

我仔细阅读了代码,所有内容似乎都与他们站点上给出的示例相匹配,但是它看起来就像是四张图像堆叠在一起,另一张堆叠在底部,而上一个和后一个按钮在底部。

在开发人员工具上查看时,单击这些按钮的确会更改各种照片中的active标签,但似乎没有任何视觉效果。

如果这是一个问题,我将遍历数据库图片,但是这些图片似乎在正确的位置出现和显示。干杯。

如果有帮助,请参见以下代码:

<div class="container">
  <div id="carouselExampleIndicators" class="carousel slide pointer-event" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1" class=""></li><li data-target="#carouselExampleIndicators" data-slide-to="2" class=""></li><li data-target="#carouselExampleIndicators" data-slide-to="3" class=""></li>  </ol>
  <div class="carousel-inner">

              <div class="carousel-item active">
              <img src="img/5c93c5fec0d110.10065506.jpg" class="d-block w-100" alt="Absolute Balderdash">
              </div>

          <div class="carousel-item">
            <img src="img/5c93c5fec16a35.12174898.jpg" class="d-block w-100" alt="Absolute Balderdash">
          </div>

          <div class="carousel-item">
            <img src="img/5c93c5fec1c830.06571881.jpg" class="d-block w-100" alt="Absolute Balderdash">
          </div>

          <div class="carousel-item">
            <img src="img/5c93c5fec20b53.10796324.jpg" class="d-block w-100" alt="Absolute Balderdash">
          </div>
            </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
</div>

1 个答案:

答案 0 :(得分:0)

完全没有错误。您可能需要检查是否必须插入所需的库。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<div class="container">
  <div id="carouselExampleIndicators" class="carousel slide pointer-event" data-ride="carousel">
    <ol class="carousel-indicators">
      <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="1" class=""></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="2" class=""></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="3" class=""></li>
    </ol>
    <div class="carousel-inner">

      <div class="carousel-item active">
        <img src="https://via.placeholder.com/120.jpg?text=First" class="d-block w-100" alt="Absolute Balderdash">
      </div>

      <div class="carousel-item">
        <img src="https://via.placeholder.com/120.jpg?text=Second" class="d-block w-100" alt="Absolute Balderdash">
      </div>

      <div class="carousel-item">
        <img src="https://via.placeholder.com/120.jpg?text=Third" class="d-block w-100" alt="Absolute Balderdash">
      </div>

      <div class="carousel-item">
        <img src="https://via.placeholder.com/120.jpg?text=Fourth" class="d-block w-100" alt="Absolute Balderdash">
      </div>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>