owl carousel slide n by n

蓝咒 提交于 2019-12-24 06:11:20

问题


Using owl carousel and trying to slide items five by five, now i have 5 items, i want when i push next or prev button it move to next five item, currently it move to next item, is it possible?

$('.owl-carousel').owlCarousel({
    loop:true,
    items:5,
    margin:10,
    nav:true
})

Demo

i googled and checked plugin website but couldn't find anything.


回答1:


Use the slideBy options in the owlCarousel config:

$('.owl-carousel').owlCarousel({
    loop:true,
    items: 5,
    margin:10,
    slideBy: 5, // slide 5 items
    nav:true
})
.item {
  background: red;
}
<link href="https://owlcarousel2.github.io/OwlCarousel2/assets/css/docs.theme.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet"/>
<link href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.theme.default.min.css" rel="stylesheet"/>
<script src="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js"></script>
<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>



回答2:


You should include slideBy: 5 or slideBy: 'page' option, as they describe it on their documentation.

https://jsfiddle.net/w3ka3vqw/151/



来源:https://stackoverflow.com/questions/43810870/owl-carousel-slide-n-by-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!