有两个owlCarousel在一个页面中完美运行,但我想更改每个轮播上的默认设置。一旦我改变了适用于两个旋转木马的效果。
我已经尝试了什么
<script>
$(document).ready(function() {
$("#owl-demo").owlCarousel1({
navigation : false,
pagination : true,
items : 1
});
});
</script>
<script>
$(document).ready(function() {
$("#owl-example").owlCarousel();
});
</script>
我想更改每个carousle的以下设置
$.fn.owlCarousel.options = {
items : 4,
itemsCustom : false,
itemsDesktop : [1199, 1],
itemsDesktopSmall : [979, 1],
itemsTablet : [768, 1],
itemsTabletSmall : false,
itemsMobile : [479, 1],
singleItem : false,
itemsScaleUp : false
}
答案 0 :(得分:5)
如果您为要定位的每个div指定一个变量,然后分配选项,请参见下面的示例;
$(document).ready(function() {
var one = $("#one");
var two = $("#two");
one.owlCarousel({
navigation : false, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
mouseDrag:false,
touchDrag:false
});
two.owlCarousel({
navigation : true, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
mouseDrag:false,
touchDrag:false,
navigationText : false,
rewindSpeed : 300,
});
});
答案 1 :(得分:1)
为了让每个猫头鹰滑块都有自己的触发器,你必须做两件事
1-每个人都有自己的作业,如上所述
$(document).ready(function() {
var one = $("#one");
var two = $("#two");
one.owlCarousel({
navigation : false, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
mouseDrag:false,
touchDrag:false
});
two.owlCarousel({
navigation : true, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
mouseDrag:false,
touchDrag:false,
navigationText : false,
rewindSpeed : 300,
});
});
2-更改按钮类名称
第一个滑块
<div class="customNavigation">
<a class="btn prev_one"><i class="fa fa-backward" aria-hidden="true"></i></a>
<a class="btn next_one"><i class="fa fa-forward" aria-hidden="true"></i></a>
<a class="btn play_one"><i class="fa fa-play" aria-hidden="true"></i></a>
<a class="btn stop_one"><i class="fa fa-pause" aria-hidden="true"></i></a>
</div>
第二张滑块
<div class="customNavigation">
<a class="btn prev_two"><i class="fa fa-backward" aria-hidden="true"></i></a>
<a class="btn next_two"><i class="fa fa-forward" aria-hidden="true"></i></a>
<a class="btn play_two"><i class="fa fa-play" aria-hidden="true"></i></a>
<a class="btn stop_two"><i class="fa fa-pause" aria-hidden="true"></i></a>
</div>
我希望对你们所有人都没问题
答案 2 :(得分:0)
要更改导航或点的类别,您可以使用Owl Carousel(https://owlcarousel2.github.io/OwlCarousel2/docs/api-classes.html)提供的类选项
$(document).ready(function() {
var one = $("#one");
var two = $("#two");
one.owlCarousel({
navContainerClass: '//YOUR CUSTOM CLASS',
dotsClass: '//YOUR CUSTOM CLASS'
});
two.owlCarousel({
navContainerClass: '//YOUR CUSTOM CLASS',
dotsClass: '//YOUR CUSTOM CLASS'
});
});
&#13;
答案 3 :(得分:0)
js代码
$("#fr-car").owlCarousel({
items: 1,
loop: false,
autoplay: true,
animateOut: 'fadeOut',
autoplayTimeout: 3000,
nav: true,
autoplayHoverPause: true
});
$('#nd-car').owlCarousel({
responsive:{
0:{
items:1,
nav:true
},
600:{
items:3,
nav:false
},
1000:{
items:5,
nav:true,
loop:false
}
}
})
HTML代码
<div id="fr-car" class="owl-carousel">
<div></div>
<div></div>
<div></div>
</div
<div id="nd-car" class="owl-carousel" >
<div></div>
<div></div>
<div></div>
</div