轮播图插件swiper

刚用swiper做轮播图的时候,我一直做不出来,后来发现原来我只引入了swiper的js,没有引入swiper的css.
这两个都是必须引入的,而jquery库无论有没有都能运行swiper.
基本结构示例:

            <!--大图开始-->
             <style>  
            img{width:100%;}
            .swiper-container {
                float:left;
                width: 50%;
                height: 280px;

            }
             </style>
             <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide"><img src="images/timg.jpg"></div>
                    <div class="swiper-slide"><img src="images/timg.jpg"></div>
                    <div class="swiper-slide"><img src="images/timg.jpg"></div>
                    <div class="swiper-slide"><img src="images/timg.jpg"></div>
                    <div class="swiper-slide"><img src="images/timg.jpg"></div>
                    <div class="swiper-slide">Slide 6</div>
                    <div class="swiper-slide">Slide 7</div>
                    <div class="swiper-slide">Slide 8</div>
                    <div class="swiper-slide">Slide 9</div>
                    <div class="swiper-slide">Slide 10</div>
                </div>
                <!-- Add Pagination -->
                <div class="swiper-pagination" style="bottom:40px;"></div>
                <!-- Add Arrows -->
                <div class="swiper-button-next"></div>
                <div class="swiper-button-prev"></div>
            </div>

            <!-- Swiper JS -->


            <!-- Initialize Swiper -->
            <script>
            var swiper = new Swiper('.swiper-container', {
                pagination: '.swiper-pagination',
                nextButton: '.swiper-button-next',
                prevButton: '.swiper-button-prev',
                paginationClickable: true,
                spaceBetween: 30,
                centeredSlides: true,
                autoplay: 2500,
                autoplayDisableOnInteraction: false
            });
            </script>
            <!--大图结束-->

这就是最基本的用法了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值