javascript - Owl Carousel 幻灯片全部显示为一张幻灯片

标签 javascript jquery css owl-carousel

我对 Owl Carousel 有疑问。我想要一个单张幻灯片的 Owl Carousel ,但我的所有图像都显示为一张幻灯片,彼此垂直对齐,而不是随着 slider 方向的移动而水平对齐。 下面我将向您提供代码和屏幕截图:

<div id="owl-demo" class="projects-slider owl-carousel owl-theme">

    <div class="item"><img src="img/lisi1.jpg" alt="lisi"></div>
    <div class="item"><img src="img/lisi2.jpg" alt="lisi"></div>
    <div class="item"><img src="img/lisi3.jpg" alt="lisi"></div>
    <div class="item"><img src="img/lisi3.jpg" alt="lisi"></div>



    </div>

CSS

.owl-carousel .item img {
    display:block;
    width:100%;
    height:auto;



}

.owl-carousel .item {
    margin:0px;

}

JS

$(document).ready(function() {

  $('.projects-slider').owlCarousel({

      navigation : true, // Show next and prev buttons
      slideSpeed : 300,
      paginationSpeed : 400,
      singleItem:true,
      pagination: true,
      items: 1,


  });

});

enter image description here

enter image description here

最佳答案

你可以试试这个:[For version 1.3.3 with jQuery 1.9.1]

在第 754 行更改 owl.carousel.js

doTranslate : function (pixels) { 
        var tmp_pixi = 0;
        tmp_pixi = (pixels % 1553);
        return {
            "-webkit-transform": "translate3d(0px, " + tmp_pixi + "px, 0px)",
            "-moz-transform": "translate3d(0px, " + tmp_pixi + "px, 0px)",
            "-o-transform": "translate3d(0px, " + tmp_pixi + "px, 0px)",
            "-ms-transform": "translate3d(0px, " + tmp_pixi + "px, 0px)",
            "transform": "translate3d(0px, " + tmp_pixi + "px,0px)"
            };           
    },

注意:350 将是图像的高度...您可以将其设置为静态方式,或者使用 jquery 使其动态化

关于javascript - Owl Carousel 幻灯片全部显示为一张幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38946893/

相关文章:

javascript - 你知道 JavaScript 中哪些因素会导致内存泄漏吗?

jquery - 通过 Ajax 加载 Facebook Like 按钮

javascript - jQuery animate - 使幻灯片图像在同一方向上迭代循环

html - CSS 无法让悬停状态在简单的 div 上运行

html - 具有背景和百分比边框宽度的 CSS 环

javascript - 如何将值列表传递到单选按钮选择中

javascript - CellTemplate ui-grid 中的 ng-if

javascript - 调整 JS Expand/Collapse 函数,它的流动性有点颠簸

html - 如何在页面加载时使用 jquery 更改图像域

html - 单元格边框显示在边框 :none td 上