swiper实现内容自适应匀速滚动
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"><img src="./img/1.png" alt=""></div> <div class="swiper-slide"><img src="./img/2.png" alt=""></div> <div class="swiper-slide"><img src="./img/3.png" alt=""></div> <div class="swiper-slide"><img src="./img/1.png" alt=""></div> <div class="swiper-slide"><img src="./img/2.png" alt=""></div> <div class="swiper-slide"><img src="./img/3.png" alt=""></div> </div> </div> <script> var swiper = new Swiper('.swiper-container', { slidesPerView: 'auto', //自适应宽度 spaceBetween: 3, //间距为3px loop: true, //循环滚动 speed: 2500, //滚动速度2500 freeMode: true, autoplay: { //匀速滚动 delay: 0, //间隔时间0秒 stopOnLastSlide: false, disableOnInteraction: false, //触摸后仍然执行 } }); </script>