1. 程式人生 > >解決 Swiper 插件autoHeight問題 建議

解決 Swiper 插件autoHeight問題 建議

swiper autoheight

var mySwiper=$(".swiper-container").swiper({

autoHeight: true,

onSlideChangeStart: function() {

var H = $(".swiper-slide").eq(mySwiper.activeIndex).find(".bigbox").height();

var scH=$(".swiper-container").height();

var bodyH=$("body").height()

if(H<scH){

console.log(scH)

alert($("body").height())

$(".swiper-slide").css(‘height‘, bodyH-20 + ‘px‘);

$(".swiper-wrapper").css(‘height‘, bodyH-20 + ‘px‘);

}else{

$(".swiper-slide").css(‘height‘, H + ‘px‘);

$(".swiper-wrapper").css(‘height‘, H + ‘px‘);

}

console.log("slideH:" + $(".swiper-slide").height())

console.log("wrapperH:" + $(".swiper-wrapper").height())

}


本文出自 “11112450” 博客,轉載請與作者聯系!

解決 Swiper 插件autoHeight問題 建議