为什么这个 Bootstrap 旋转木马不工作?

lkaoscv7  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(2)|浏览(154)

IMAGE IS WHAT I SEE
我试过CSS和其他的方法,但是没有用。
错误:照片是一张接一张显示的,而且不是“carousel”样式。看起来好像我只是把照片贴在代码上,根本没有carousel。
下面是我的代码:

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
        <img src="couple-walking-dog-in-front-of-well_orig.jpg" />
    </div>

    <div class="item">
        <img src="th.jpg" />
    </div>

    <div class="item">
        <img src="victory-girl_orig.jpg" />
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
eiee3dmh

eiee3dmh1#

您的类名中有一些错误。item应该是carousel-itemleft carousel control应该是carousel-control-prev,还有一些错误。
修复这些问题应该会给予您想要的结果:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="carousel-item active">
        <img class="d-block w-100" src="https://via.placeholder.com/350x150" />
    </div>

    <div class="carousel-item">
        <img class="d-block w-100" src="https://via.placeholder.com/350x150" />
    </div>

    <div class="carousel-item">
        <img class="d-block w-100" src="https://via.placeholder.com/350x150" />
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
n6lpvg4x

n6lpvg4x2#

您似乎遗漏了类名。您的代码

<div class="carousel-inner">
    <div class="item active">

看样子最后一堂课应该是:“* 转盘项目活动 ”,而不仅仅是:“ 项目活动 *”

相关问题