gpt4 book ai didi

swiper.js - SwiperJS : Custom speed/delay for each slide?

转载 作者:行者123 更新时间:2023-12-01 21:46:09 36 4
gpt4 key购买 nike

  • Swiper 版本:5.3。

我想知道在 Swiper JS 中是否有设置单个幻灯片持续时间/延迟的选项盒子外面。我在文档、github 问题中进行了搜索,但找不到任何相关内容。

如果开箱即用,谁能展示如何通过破解核心或自定义代码来实现这一目标。

谢谢。

最佳答案

数据刷卡自动播放

data-swiper-autoplay 属性:

https://swiperjs.com/swiper-api#param-autoplay

Delay between transitions (in ms). If this parameter is not specified,auto play will be disabled

If you need to specify different delay for specific slides you can doit by using data-swiper-autoplay (in ms) attribute on slide:

<!-- hold this slide for 2 seconds -->
<div class="swiper-slide" data-swiper-autoplay="2000">

例子:

html, body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color:#000;
margin: 0;
padding: 0;
}
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;

/* Center slide text vertically */
display: flex;
justify-content: center;
align-items: center;
}
<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="https://unpkg.com/swiper@7.0.1/swiper-bundle.min.css">
</head>

<body>
<!-- Swiper -->
<h1>Swiper 7 data-swiper-autoplay</h1>
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide" data-swiper-autoplay="3000">3 seconds</div>
<div class="swiper-slide" data-swiper-autoplay="4000">4 seconds</div>
<div class="swiper-slide" data-swiper-autoplay="5000">5 seconds</div>
</div>
<!-- Add Arrows -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>

<!-- Swiper JS -->
<script src="https://unpkg.com/swiper@7.0.1/swiper-bundle.min.js"></script>

<!-- Initialize Swiper -->
<script>
var swiper = new Swiper('.swiper', {
initialSlide: 1,
slidesPerView: 1,
spaceBetween: 20,
autoplay: {
delay: 2000,
},
centeredSlides: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
</script>

关于swiper.js - SwiperJS : Custom speed/delay for each slide?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60438838/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com