ITPub博客

首页 > IT职业 > IT生活 > 解决 Swiper 插件autoHeight问题 建议

解决 Swiper 插件autoHeight问题 建议

IT生活 作者:welchang 时间:2021-09-09 10:03:41 0 删除 编辑

 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())

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4830/viewspace-2815722/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: JS速查手册
请登录后发表评论 登录
全部评论

注册时间:2019-07-17

  • 博文量
    252
  • 访问量
    17973