时间:2021-07-01 10:21:17 帮助过:20人阅读
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide" style="background-image:url(img/4.jpg)"> 第一页 </div> <div class="swiper-slide" style="background-image:url(img/5.jpg)"> 第二页 </div> <div class="swiper-slide" style="background-image:url(img/6.jpg)"> 第三页 </div> </div> <div class="swiper-pagination swiper-pagination-white"></div> <div class="swiper-button-next swiper-button-white"></div> <div class="swiper-button-prev swiper-button-white"></div> </div>
为了动画效果明显,我在每个slide当中添加了背景图片。
然后在JS当中进行初始化,并且添加翻页动画的属性。
var swiper = new Swiper('.swiper-container',{ pagination:'.swiper-pagination', paginationClickable:true, nextButton:'.swiper-button-next', prevButton:'.swiper-button-prev', effect:'fade' //动画效果:渐变 });
这样就实现了渐变的翻页动画,很简单,就是在初始化当中添加了一条属性(effect:'fade')
以上就是swiper的基础使用(十五)的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!