最近给公司开发手机端网站,发现一个很厉害的插件
swiper,这个插件可以做出很多漂亮的滑动的图片效果,暂时在使用的时候我发现所有的特效样式都是一样的。用的是相同的class swiper-container和swiper-pagination,怎么将他们分来呢?我中间换了类名,但是出不来效果,最后我换成这样的,请注意红色的部分:
$(function(){
var mySwiper = $('.banner .swiper-container').swiper({
mode:'horizontal',
loop: true,
autoResize:true,
pagination:'.banner .swiper-pagination',
paginationClickable :true,
autoplay : 3000,
});
var swiper = $('.case .swiper-container').swiper({
pagination: '.case .swiper-pagination',
slidesPerView: 4,
slidesPerColumn: 2,
paginationClickable: true,
spaceBetween: 20
});
})
最终出来了效果,
获取他们共用的class的时候加上父元素区分开。
写style的时候.swiper-container和.swiper-paginatio是共用的不要写在里面新建class区分写改变它们不同的样式。