时间:2021-07-01 10:21:17 帮助过:70人阅读
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide">H5EDU 1<img src="logo.png"></div> <div class="swiper-slide">H5EDU 2<img src="logo.png"></div> <div class="swiper-slide">H5EDU 3<img src="logo.png"></div> <div class="swiper-slide">H5EDU 4<img src="logo.png"></div> <div class="swiper-slide">H5EDU 5<img src="logo.png"></div> <div class="swiper-slide">H5EDU 6<img src="logo.png"></div> <div class="swiper-slide">H5EDU 7<img src="logo.png"></div> <div class="swiper-slide">H5EDU 8<img src="logo.png"></div> <div class="swiper-slide">H5EDU 9<img src="logo.png"></div> </div> <div class="swiper-scrollbar"></div> </div>
然后到JS部分添加初始化代码。
var swiper = new Swiper('.swiper-container',{ spaceBetween:30, grabCursor:true, slidesPerView:3, centeredSlides:true, scrollbar:'.swiper-scrollbar', //绑定分页导航 scrollbarHide:true //开启导航在不活动时的隐藏 });
可以注意到在本篇当中将分页导航的swiper-container改变为swiper-scrollbar,然后在初始化当中绑定导航。就可以实现了。当然,可以关闭导航条的隐藏效果
以上就是swiper的基础教程(十二)的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!