原生JS,html,css 一个页面使用多个swiper轮播图,以及swiper轮播图单轮播,多重轮播 源码demo,以及叠加显示隐藏切换问题,多轮播嵌套鼠标悬停等问题,循环播放无停顿设置

本文详细介绍了如何利用原生JS和Swiper实现循环播放无停顿的轮播图功能,同时解决了多轮播图在显示与隐藏时的自动切换问题。内容包括swiper的鼠标悬停控制、轮播图嵌套以及循环播放设置。通过提供多个实际的代码示例,帮助读者理解和应用。
摘要由CSDN通过智能技术生成

如果你想使用轮播图请先去swiper官网查看实例看是否有你需要的swiper官网
由于下面内容过长先给大家讲几种swiperd 功能
*

(1)swiper循环播放且无停顿 功能*

css

#thumbs5 .swiper-wrapper,{
   
    -webkit-transition-timing-function: linear !important; /*之前是ease-out*/
    -moz-transition-timing-function: linear !important;
    -ms-transition-timing-function: linear !important;
    -o-transition-timing-function: linear !important;
    transition-timing-function: linear !important;
}
js
   var mySwipers3 = new Swiper("#thumbs5 .swiper-containers", {
        spaceBetween: 10,
        loop: true,
        speed:2000,//设置匀速运行时间
        slidesPerView: 'auto',
        direction: 'vertical',
        loopedSlides: 0,
        grabCursor: true,  //开启抓手光标
        autoplay: {
            delay: 0, //将值设置为零页面会无停顿感
            stopOnLastSlide: false,
            disableOnInteraction: false,
        },
    });

(2)swiper的几种悬停(鼠标移入停止 移出继续轮播)*

 单轮播图
var mySwiper1 = new Swiper("#swiper1", {
   
    spaceBetween: 10,
    loop: true,
    speed:2000,//匀速时间
    slidesPerView: 'auto',
    direction: 'vertical',
    loopedSlides: 0,
    boolean: false,
    grabCursor: true,  //开启抓手光标
    autoplay: {
   
        delay: 0,
        stopOnLastSlide: false,
        disableOnInteraction: false,
    }

});



//鼠标移入停止自动切换
mySwiper1.el.onmouseover = function () {
   
    mySwiper1.autoplay.stop();
}

//鼠标离开开始自动切换
mySwiper1.el.onmouseout = function () {
   
    mySwiper1.autoplay.start();
}

 双轮播图
  var galleryThumbs3 = new Swiper('#thumbs3', {
   
        observer:true,//修改swiper自己或子元素时,自动初始化swiper
        observeParents:true,//修改swiper的父元素时,自动初始化swiper
        spaceBetween: 10,
        slidesPerView: 4,
        freeMode: true,
        watchSlidesVisibility: true,
        watchSlidesProgress: true,

    });
    var galleryTops = new Swiper('#gallery3', {
   
        
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值