javascript - Owl Carousel 2 无法在调整窗口大小上工作

标签 javascript jquery css responsive-design owl-carousel

我在我的页面中使用 Owl carousel 2,我想像这里一样使用 Stage padding 选项: http://www.owlcarousel.owlgraphic.com/demos/stagepadding.html

这是我的 HTML:

 <div class="owl-carousel">
   <div class="item"></div>
   <div class="item"></div>
   <div class="item"></div>
   <div class="item"></div>
 </div>

我的CSS:

 .item {
   background-image: url("myimage.png");
   background-repeat: no-repeat;
   background-size: contain;
   height: 10rem;
 }

和我的js:

 var owloptions = {
    stagePadding: 50,
    loop:true,
    margin:10,
    nav: true,
    dots: false,
    responsive:{
        0:{
            items:2
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
}

$('.owl-carousel').owlCarousel(owloptions);

我的问题是响应不起作用。它仅适用于重新加载页面,但不适用于调整大小时。我想知道是 css 还是 js 出了问题?提前致谢

最佳答案

       responsive: {
              0: {
                items: 1,
                nav: true
              },
              600: {
                items: 3,
                nav: false
              },
              1000: {
                items: 5,
                nav: true,
                loop: false,
                margin: 20
              }
            }

在文档准备好时试试这个

 $(document).ready(function() {
          $('.owl-carousel').owlCarousel({

关于javascript - Owl Carousel 2 无法在调整窗口大小上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33999972/

相关文章:

javascript - jquery 代码可以在 Mozilla 中运行,但不能在其他浏览器中运行

jquery - 滚动时降低div的高度

jquery - 修改 jQuery Mobile (jqm) 文件上传按钮

jQuery 狭缝 slider 问题

javascript - 当 ng-show ="true"时我的元素没有出现?

css - div重叠/错位

javascript - 如何使用 jQuery 根据用户输入创建 javascript 数组

javascript - ajax加载所有DOM元素后如何加载函数

javascript - 如何解决 Javascript 中的圈复杂度

javascript - 如何使用js格式化HTML日期选择器