您的位置:首页 > Web前端 > HTML

HTML轮播记住一定要导入两个包

2017-10-08 19:31 183 查看
/////////////////////////////////////////////////////HTML代码

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Title</title>

    <script src="js/swiper-3.4.2.min.js"></script>

    <link href="css/swiper.min.css" rel="stylesheet">

    <style>

        .swiper-container {

            width: 600px;

            height: 300px;

        }

        .blue{

            background: blue;

        }

        .yellow{

            background: yellow;

        }

        .red{

            background: red;

        }

        .swiper-pagination-bullet{

            background: #fff;

            width: 20px;

            height: 20px;

        }

    </style>

</head>

<body>

    <div class="swiper-container">

        <div class="swiper-wrapper">

            <div class="swiper-slide red">Slide 1</div>

            <div class="swiper-slide yellow">Slide 2</div>

            <div class="swiper-slide blue">Slide 3</div>

        </div>

        <!-- 如果需要分页器 -->

        <div class="swiper-pagination"></div>

        <!-- 如果需要导航按钮 -->

        <div class="swiper-button-prev"></div>

        <div class="swiper-button-next"></div>

        <!-- 如果需要滚动条 -->

       <!-- <div class="swiper-scrollbar"></div>-->

    </div>

    <script>

        var mySwiper = new Swiper ('.swiper-container', {

            direction: 'horizontal',

            loop: true,

            autoplay : 2000,

            // 如果需要分页器

            pagination: '.swiper-pagination',

            paginationClickable :true,

            // 如果需要前进后退按钮

            nextButton: '.swiper-button-next',

            prevButton: '.swiper-button-prev',

            // 如果需要滚动条

           /* scrollbar: '.swiper-scrollbar',*/

        })

    </script>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: