4

有两个 owlCarousel 在一个页面中完美运行,但我想更改每个轮播的默认设置。一旦我更改了适用于两个轮播的效果。

我已经尝试过的

<script>
    $(document).ready(function() {
      $("#owl-demo").owlCarousel1({
        navigation : false,
        pagination : true,
        items : 1
      });
    });

</script>
<script>
    $(document).ready(function() {

    $("#owl-example").owlCarousel();


    });
</script>

我想为每个轮播更改以下设置

 $.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
}
4

4 回答 4

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,
  });

});
于 2014-09-17T14:00:31.427 回答
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>

我希望对你们所有人都好

于 2016-09-17T13:33:15.630 回答
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'
  });

});

于 2018-06-05T08:28:28.203 回答
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
于 2020-06-21T14:30:05.180 回答