Bootstrap 4旋转木马不工作? [英] Bootstrap 4 carousel not working?

查看:214
本文介绍了Bootstrap 4旋转木马不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下BS4 Carousel代码,(使用本教程制作 https://www.youtube.com/watch?v=n8ItscKLf7s&list=PLRtjMdoYXLf47brThg9-nTj8HSq8cQ0ND&index=53 ),但代码不起作用,显示第一个图像,但显示I不知道旋转木马没有受到控制的原因,在任何情况下它都不会进入下一个图像。可能的解决方案是什么?

I have the following BS4 Carousel code, (made it using this tutorial https://www.youtube.com/watch?v=n8ItscKLf7s&list=PLRtjMdoYXLf47brThg9-nTj8HSq8cQ0ND&index=53), However the code is not working, the first image is displayed but I dont know for what reasons carousel is not controlled and it does'nt go to the next image in any case. What is the possible solution?

<div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                <br />
                <div id="carousel-example-generic" class="carousel-slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"> </li>
                     <li data-target="#carousel-example-generic" data-slide-to="1"> </li>
                     <li data-target="#carousel-example-generic" data-slide-to="2"> </li>
                    </ol>

                    <div class="carousel-inner" role="listbox">
                        <div class="carousel-item-active">
                            <img src="images/1.jpeg" alt="First-Slide">
                        </div>
                        <div class="carousel-item">
                            <img src="images/2.jpeg" alt="Second-Slide">
                        </div>
                        <div class="carousel-item">
                            <img src="images/3.jpeg" alt="Third-Slide">
                        </div>
                    </div>
                    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> 
                    <span class="icon-prev" aria-hidden="true"></span>
                    <span class="sr-only"> Previous </span>
                    </a>
                    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> 
                    <span class="icon-next" aria-hidden="true"></span>
                    <span class="sr-only"> Next </span>
                    </a>
                </div>
            </div>
        </div>
    </div>


推荐答案

完美呈现

<!DOCTYPE html>
<html lang="en">
<head>
  <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>

<div class="container">
  <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="https://www.w3schools.com/bootstrap/ny.jpg" alt="Los Angeles" style="width:100%;">
      </div>

      <div class="item">
        <img src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="Chicago" style="width:100%;">
      </div>
    
      <div class="item">
        <img src="https://www.w3schools.com/bootstrap/newyork.jpg" alt="New york" style="width:100%;">
      </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>
</div>

</body>
</html>

这篇关于Bootstrap 4旋转木马不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆