设置项为1
为了使猫头鹰旋转木马2显示单个响应幻灯片您需要设置项目数量为1而不是默认值3,因此您不需要使用the docs中提供的响应选项,因为您总是希望显示一张幻灯片。
的JavaScript
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:true,
items: 1
})
全码
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:true,
items: 1
})
.item {
background-color: #4DC7A0;
color: white;
font-size: 30px;
height: 150px;
padding: 10px;
}
<link href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.theme.default.min.css" rel="stylesheet"/>
<link href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<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>
是否在[文档首页]演示(https://owlcarousel2.github.io/OwlCarousel2/)做你在期待什么?它表示它的响应速度很快 – adriancarriger
@adriancarriger它按照我的预期行事,但它不是我想要的。响应功能对我没有帮助,因为它似乎以一次显示的项目数量开头,我希望始终显示一个项目,因此显示的项目计数更改对我无效。我只想让滑块在重要元素上不产生固定宽度的情况下工作。 –