具体可以参考:http://www.runoob.com/bootstrap/bootstrap-carousel-plugin.html

 

一、轮播图

<div id="myCarousel" class="carousel slide">
    <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>
    <div class="carousel-inner">
        <div class="item active" style="background:#223240;">
            <a href="#"><img src="img/slide1.png" alt="第一张"></a>
        </div>
        <div class="item" style="background:#F5E4DC;">
            <a href="#"><img src="img/slide2.png" alt="第二张"></a>
        </div>
        <div class="item" style="background:#DE2A2D;">
            <a href="#"><img src="img/slide3.png" alt="第三张"></a>
        </div>
    </div>
    <a href="#myCarousel" data-slide="prev" class="carousel-control left">
        <span class="glyphicon glyphicon-chevron-left"></span> </a>
    <a href="#myCarousel" data-slide="next"  class="carousel-control right">
        <span class="glyphicon glyphicon-chevron-right"></span> </a>
</div>
  • 所需的css如下
 <style>
        a:focus {
            outline: none;
        }

        .navbar-brand {
            padding: 0;
        }

        #myCarousel {
            margin: 50px 0 0 0;
        }

        .carousel-inner .item img {
            margin: 0 auto;
        }

        .carousel-control {
            font-size: 100px;
        }

    </style>
  • 结果如下图

 

版权声明:本文为shyroke原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/shyroke/p/9237330.html