【问题标题】:owl-carousel automatic slider not workingowl-carousel 自动滑块不工作
【发布时间】:2019-10-03 05:11:18
【问题描述】:

css:owl.carousel.min.css

.owl-carousel,
.owl-carousel .owl-item {
    -webkit-tap-highlight-color: transparent;
    position: relative
}

.owl-carousel {
    display: none;
    width: 100%;
    z-index: 1
}

.owl-carousel .owl-stage {
    position: relative;
    -ms-touch-action: pan-Y;
    -moz-backface-visibility: hidden
}

.owl-carousel .owl-stage:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0
}

.owl-carousel .owl-stage-outer {
    position: relative;
    overflow: hidden;
    -webkit-transform: translate3d(0, 0, 0)
}

.owl-carousel .owl-item,
.owl-carousel .owl-wrapper {
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -ms-backface-visibility: hidden;
    -webkit-transform: translate3d(0, 0, 0);
    -moz-transform: translate3d(0, 0, 0);
    -ms-transform: translate3d(0, 0, 0)
}

.owl-carousel .owl-item {
    min-height: 1px;
    float: left;
    -webkit-backface-visibility: hidden;
    -webkit-touch-callout: none
}

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

.owl-carousel .owl-dots.disabled,
.owl-carousel .owl-nav.disabled {
    display: none
}

.no-js .owl-carousel,
.owl-carousel.owl-loaded {
    display: block
}

.owl-carousel .owl-dot,
.owl-carousel .owl-nav .owl-next,
.owl-carousel .owl-nav .owl-prev {
    cursor: pointer;
    cursor: hand;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none
}

.owl-carousel.owl-loading {
    opacity: 0;
    display: block
}

.owl-carousel.owl-hidden {
    opacity: 0
}

.owl-carousel.owl-refresh .owl-item {
    visibility: hidden
}

.owl-carousel.owl-drag .owl-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none
}

.owl-carousel.owl-grab {
    cursor: move;
    cursor: grab
}

.owl-carousel.owl-rtl {
    direction: rtl
}

.owl-carousel.owl-rtl .owl-item {
    float: right
}

.owl-carousel .animated {
    animation-duration: 1s;
    animation-fill-mode: both
}

.owl-carousel .owl-animated-in {
    z-index: 0
}

.owl-carousel .owl-animated-out {
    z-index: 1
}

.owl-carousel .fadeOut {
    animation-name: fadeOut
}

@keyframes fadeOut {
    0% {
        opacity: 1
    }
    100% {
        opacity: 0
    }
}

.owl-height {
    transition: height .5s ease-in-out
}

.owl-carousel .owl-item .owl-lazy {
    opacity: 0;
    transition: opacity .4s ease
}

.owl-carousel .owl-item img.owl-lazy {
    transform-style: preserve-3d
}

.owl-carousel .owl-video-wrapper {
    position: relative;
    height: 100%;
    background: #000
}

.owl-carousel .owl-video-play-icon {
    position: absolute;
    height: 80px;
    width: 80px;
    left: 50%;
    top: 50%;
    margin-left: -40px;
    margin-top: -40px;
    background: url(owl.video.play.html) no-repeat;
    cursor: pointer;
    z-index: 1;
    -webkit-backface-visibility: hidden;
    transition: transform .1s ease
}

.owl-carousel .owl-video-play-icon:hover {
    -ms-transform: scale(1.3, 1.3);
    transform: scale(1.3, 1.3)
}

.owl-carousel .owl-video-playing .owl-video-play-icon,
.owl-carousel .owl-video-playing .owl-video-tn {
    display: none
}

.owl-carousel .owl-video-tn {
    opacity: 0;
    height: 100%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    transition: opacity .4s ease
}

.owl-carousel .owl-video-frame {
    position: relative;
    z-index: 1;
    height: 100%;
    width: 100%
}

.owl-carousel .owl-wrapper-outer{
    overflow: hidden;
    position: relative;
    width: 100%;
    z-index: 1;
}
.owl-item { 
    transform: translateZ(0);
    -webkit-transform: translateZ(0); 
    -ms-transform: translateZ(0);
}

index.php

<script>
    $(document).ready(function(){
        $(".owl-carousel").owlCarousel({
            navigation : false,
            rtl:true,
            slideSpeed : 300,
            paginationSpeed : 400,
            singleItem:true
        }); 
    });
</script>
<div class="col-xl-12">
    <div class="product-tab-content">
        <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
                <div class="product-active owl-carousel">
                    <?php
                        foreach($deal as $row)
                        {
                            $img = explode(",",$row['product_image']);
                    ?>
                            <div class="pro-item">
                                <div class="product-wrapper">
                                    <div class="product-img">
                                        <a href="<?php echo base_url(); ?>details/<?php echo $row['product_id']; ?>">
                                            <?php
                                                if(!empty($img[0]))
                                                {
                                            ?>
                                                    <img src="<?php echo base_url(); ?>product/<?php echo $img[0]; ?>" alt="">
                                            <?php
                                                }
                                                else
                                                {
                                            ?>
                                                    <img src="<?php echo base_url(); ?>product/product_not.jpeg">
                                            <?php
                                                }
                                            ?>
                                        </a>
                                    </div>
                                    <div class="product-content pt-15">
                                        <h4>
                                            <a href="<?php echo base_url(); ?>details/<?php echo $row['product_id']; ?>"><?php echo $row['product_name']; ?></a>
                                        </h4>
                                        <div class="product-meta">
                                            <div class="pro-price f-left">
                                                <span><?php echo $row['unit_price']; ?></span>
                                                <span class="old-price"><?php echo $row['old_price']; ?></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                    <?php
                        }
                    ?>
                </div>
            </div>
        </div>
    </div>
</div>

我正在开发一个电子商务网站,我正在展示一些完美展示的产品,并且上一个和下一个按钮也可以正常工作,但产品不会自动滑动。我尝试了很多类似 jquery、css 的东西,但我找不到任何解决方案。如何自动滑动我的产品?请帮帮我。

谢谢

【问题讨论】:

  • 请任何人帮助我。
  • 你的js在哪里? OWl carousel有自动播放选项,需要设置为true,//默认设置:autoplay:false autoplayTimeout:5000 autoplayHoverPause:false
  • 请看@Ravi
  • 在你的 JS owlCarousel 中设置 autoplay:true;。 @samorten
  • 我试过@Nayeem但没有工作:(

标签: php jquery html css


【解决方案1】:

将你的 js 代码放在 html 下方,并将 (autoplay:true) 行添加到函数中。

$(document).ready(function(){ $(".owl-carousel").owlCarousel({ navigation : false, rtl:true, slideSpeed : 300, paginationSpeed : 400, autoplay:true, singleItem:true }); });

【讨论】:

    【解决方案2】:

    你可以使用Swiper 比猫头鹰轮播更好。

    刷卡器 - 是免费且最现代的移动触摸滑块,具有硬件加速过渡和惊人的原生行为。它旨在用于移动网站、移动 Web 应用程序和移动原生/混合应用程序。主要为 iOS 设计,但也适用于最新的 Android、Windows Phone 8 和现代桌面浏览器。

    Swiper 并不兼容所有平台,它是一种现代风格 滑块仅专注于现代应用程序/平台,以带来 最佳体验和简单性。

    【讨论】:

      【解决方案3】:

      owl.carousel.js 文件中

      搜索转换你应该找到类似的东西

      transform: 'translate3d("+b+"px,0px,0px)'

      看到这个"+b+""+-b+" 替换它,结果是这样的

      transform: "translate3d(" + -b + "px,0px, 0px)"

      请注意,这在 ltr 版本中不起作用,所以在我的情况下,我使用的是动态应用程序,因此制作了 2 个文件,我将英文版本称为不带减号 " + b + "rtl 我添加了这个减号。

      它可能对某人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-11
        • 2018-09-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-29
        • 2022-01-01
        • 1970-01-01
        相关资源
        最近更新 更多