Bootstrap 4多项目轮播没有响应,在桌面的角落仅显示一项

问题描述

我想在英雄之前在顶部添加第二个轮播,一个区别是它应该是多个项目,但只显示一个项目。

也许是因为较大的轮播,每个幻灯片显示一项。

引导程序4

    <div class="container-fluid mt-5">

  <!-- Grid row -->
  <div class="row">

    <!-- Grid column -->
    <div class="col-md-12 mb-4">

      <div class="container text-center my-3">
        <div class="row my-auto">
          <div id="recipeCarousel2" class="carousel slide w-100 " data-ride="carousel">
            <div class="carousel-inner w-100 vv-3" role="listBox">
              <div class="carousel-item active">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
              <div class="carousel-item">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
              <div class="carousel-item">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
              <div class="carousel-item">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
              <div class="carousel-item">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
              <div class="carousel-item">
                <div class="col-2">
                  <img class="d-block img-fluid"
                    src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg">
                </div>
              </div>
            </div>
            <a class="carousel-control-prev" href="#recipeCarousel2" 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="#recipeCarousel2" role="button" data-slide="next">
              <span class="carousel-control-next-icon" aria-hidden="true"></span>
              <span class="sr-only">Next</span>
            </a>
          </div>
        </div>
      </div>

    </div>
    <!-- Grid column -->

  </div>
  <!-- Grid row -->
  
</div>

enter image description here

解决方法

在引导程序中使用多个图像的单个轮播和在单行中具有不同列的多个图像的多个轮播。

下面,引导中的Carousel代码。请让我知道你是否想要 一样还是不一样。

轮播使用多个图像。

<!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/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <style>
 
  .carousel-inner img {
    width: 100%;
    height: 50%;
  }
  </style>
</head>
<body>

<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>
  
  <!-- carousel slideshow -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" alt="" width="1100" height="500">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" alt="" width="1100" height="500">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" alt="" 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>

</body>
</html>

连续的多个轮播,在引导程序中有多个列。

<!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/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <style>

  .carousel-inner img {
    width: 100%;
    height: 50%;
  }
  </style>
</head>
<body>

<div class="container">
  <div class="row">
    <div class="col-4">
        <div id="carosel1" class="carousel slide" data-ride="carousel">

  <!-- Indicators -->
  <ul class="carousel-indicators">
    <li data-target="#carosel1" data-slide-to="0" class="active"></li>
    <li data-target="#carosel1" data-slide-to="1"></li>
    <li data-target="#carosel1" data-slide-to="2"></li>
  </ul>
  
  <!-- Carousel slideshow -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
  </div>
  
  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#carosel1" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#carosel1" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
    </div>
    
    <div class="col-4">
        <div id="carosel2" class="carousel slide" data-ride="carousel">

  <!-- Indicators -->
  <ul class="carousel-indicators">
    <li data-target="#carosel2" data-slide-to="0"></li>
    <li data-target="#carosel2" data-slide-to="1" class="active"></li>
    <li data-target="#carosel2" data-slide-to="2"></li>
  </ul>
  
  <!-- Carousle slideshow -->
  <div class="carousel-inner">
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item active">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
  </div>
  
  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#carosel2" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#carosel2" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
    </div>
    
    <div class="col-4">
        <div id="carosel3" class="carousel slide" data-ride="carousel">

  <!-- Indicators -->
  <ul class="carousel-indicators">
    <li data-target="#carosel3" data-slide-to="0"></li>
    <li data-target="#carosel3" data-slide-to="1"></li>
    <li data-target="#carosel3" data-slide-to="2"  class="active"></li>
  </ul>
  
  <!-- Carousel slideshow -->
  <div class="carousel-inner">
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
    <div class="carousel-item active">
      <img src="https://mdbootstrap.com/img/Photos/Others/images/43.jpg" width="100" height="50">
    </div>
  </div>
  
  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#carosel3" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#carosel3" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
    </div>
  </div>
</div>


</body>
</html>