当"项目"是分数并且循环为假时,猫头鹰轮播不会滑动下一个项目



如果我将items属性设置为分形数(例如:1.3(,则轮播无法使用鼠标拖动滑动。它"跳"回第一项。

使用点或导航就可以了。

$('.my-carousel').owlCarousel({
items: 1.3,
margin: 10
// If `loop` is set to `true`, this problem does not happen;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<div class="my-carousel owl-carousel">
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=1">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=2">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=3">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=4">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=5">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=6">
</div>
</div>

实际上,这样做的原因是当您拥有最后一张幻灯片时。当您在最后一张幻灯片上时会发生什么。猫头鹰旋转木马不会在那里显示半个项目,这会阻止它工作。 不建议使用上述在物品中使用分数的猫头鹰轮播方法。如果要显示 1 个半项目使用

stagePadding: value

在猫头鹰旋转木马的选项中。如果您只想在一侧填充,请使用以下 CSS
工作示例

$('.my-carousel').owlCarousel({
items: 1,
margin: 10,
stagePadding: 100
});
.owl-carousel .owl-stage {
padding-left: 0 !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<div class="my-carousel owl-carousel">
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=1">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=2">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=3">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=4">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/000000/cacaca/?text=5">
</div>
<div class="my-carousel__item">
<img src="//placehold.it/256x256/cacaca/000000/?text=6">
</div>
</div>

相关内容

  • 没有找到相关文章

最新更新