gpt4 book ai didi

javascript - OWL Carousel 2 - 滑动超过 1 个带点的元素

转载 作者:太空宇宙 更新时间:2023-11-04 06:03:43 24 4
gpt4 key购买 nike

我使用 OWL Carousel 2,我禁用了导航,我想使用 Dots 进行导航。

现在我有 15 个元素,我也有 15 个点,有没有什么办法可以有 3 个点,并在我按下第一个点时滑动 5​​ 个元素?就像这张图片:

enter image description here

提前致谢

最佳答案

试试这段代码

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="owl-carousel owl-theme">
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
<div class="item"><h4>7</h4></div>
<div class="item"><h4>8</h4></div>
<div class="item"><h4>9</h4></div>
<div class="item"><h4>10</h4></div>
<div class="item"><h4>11</h4></div>
<div class="item"><h4>12</h4></div>
<div class="item"><h4>13</h4></div>
<div class="item"><h4>14</h4></div>
<div class="item"><h4>15</h4></div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><!-- latest jquery file -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<script type="text/javascript">
(function ($) {
'use strict';
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:false,
dots:true,
responsive:{
0:{
items:1
},
600:{
items:3
},
1000:{
items:5
}
}
})

})(jQuery);
</script>


</body>
</html>

CSS:

.item{
border: 1px solid #000;
background-color: red;
text-align: center;
}

关于javascript - OWL Carousel 2 - 滑动超过 1 个带点的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57057739/

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