我使用OWL Carousel 2,我禁用了导航功能,并且想使用Dots进行导航。
现在我有15个项目,我也有15个点,当我按第一个Dot时,有没有办法拥有3个点并滑动5个项目?就像这张图片一样:
提前谢谢
答案 0 :(得分:1)
尝试此代码
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;
}