轮播指标不起作用。我不知道为什么

时间:2019-08-30 14:30:32

标签: html twitter-bootstrap carousel

我无法使用指示器无法正常工作的旋转木马图像。我找不到我在做错的事情。没有css或js只是自举。当我单击指示器没有发生任何事情时,仅活动幻灯片可见。

 <link rel="stylesheet" href="inc/css/bootstrap.css">
    <link rel="stylesheet" href="inc/css/styles.css">


<!-- Start Img Slider -->
<div id="slide " class="carousel h-100 mw-100 " data-ride="carousel">
    <ol class="carousel-indicators ">
        <li data-target="slide" data-slide-to="0" class="active"></li>
        <li data-target="slide" data-slide-to="1"></li>
        <li data-target="slide" data-slide-to="2"></li>
    </ol>

    <div class="carousel-inner img-fluid" role=listbox>
        <!-- slide 1 -->
        <div class="carousel-item active " style="background-image: url(images/team1.jpg); background-repeat: no-repeat;">
            <div class="carousel-caption">
            </div>
        </div>
        <!-- slide 2 -->
        <div class="carousel-item  " style="background-image: url(images/team2.png); background-repeat: no-repeat;">
            <div class="carousel-caption">
            </div>
        </div>
        <!-- slide 3 -->
        <div class="carousel-item  " style="background-image: url(images/team3.png); background-repeat: no-repeat;">
            <div class="carousel-caption">
            </div>
        </div>
    </div>
</div>
<!--  end Img Slider -->

<script src="inc/js/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="inc/js/bootstrap.js"></script>

更新已解决!!!

只需在数据目标上忘记#

    <ol class="carousel-indicators ">
        <li data-target="#slide" data-slide-to="0" class="active"></li>
        <li data-target="#slide" data-slide-to="1"></li>
        <li data-target="#slide" data-slide-to="2"></li>
    </ol>

2 个答案:

答案 0 :(得分:0)

您需要为指标控件添加以下内容:

  <a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>

请参考此以获取更多信息/示例:

https://getbootstrap.com/docs/4.3/components/carousel/

答案 1 :(得分:-1)

您错过了双引号(“) 我相信你的问题就是这个

    <div class="carousel-inner img-fluid" role=listbox>

替换为此

    <div class="carousel-inner img-fluid" role="listbox">