简体   繁体   English

当显示的幻灯片总数和幻灯片总数相等并且滑块也不滑动时,隐藏滑动滑块箭头

[英]Slick slider arrows hidden when total number of slides and slides shown are equal and the slider is not sliding also

So I have tried many ways.所以我尝试了很多方法。 What I'm trying to achieve is I only have 3 slides but show 3 slides also.我想要实现的是我只有 3 张幻灯片,但也显示了 3 张幻灯片。 Whenever I put slidesToShow: 3 the slider stops working and arrows hidden.每当我把slidesToShow: 3滑块停止工作并隐藏箭头。

My code is below.我的代码如下。 Please help.请帮忙。

 $('.slider-for').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: false, fade: false, asNavFor: '.slider-nav', initialSlide: 0, }); $('.slider-nav').slick({ slidesToShow: 3, slidesToScroll: 1, asNavFor: '.slider-for', dots: false, focusOnSelect: true, arrows: true, });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.5.0/slick.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.css" /> <div class="slider slider-for"> <div> <div class="quote"> <h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore</h4> </div> </div> <div> <div class="quote"> <h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore</h4> </div> </div> <div> <div class="quote"> <h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore</h4> </div> </div> </div> <div class="slider slider-nav"> <div> <div class="quote-image"> <img src="https://demo.plugins360.com/wp-content/uploads/2017/12/demo.png" alt="" width="200px"> </div> </div> <div> <div class="quote-image"> <img src="https://demo.plugins360.com/wp-content/uploads/2017/12/demo.png" alt="" width="200px"> </div> </div> <div> <div class="quote-image"> <img src="https://demo.plugins360.com/wp-content/uploads/2017/12/demo.png" alt="" width="200px"> </div> </div> </div>

If you only have 3 slides and slidesToShow: 3 , there's nothing to scroll.如果您只有 3 张幻灯片和slidesToShow: 3 ,则无需滚动。 If the slides are not fully visible, you could try removing your centerMode: true setting.如果幻灯片不完全可见,您可以尝试删除centerMode: true设置。

$('.slider-nav').slick({
    slidesToShow: 3,
    slidesToScroll: 1,
    asNavFor: '.slider-for',
    dots: false,
    focusOnSelect: true,
    arrows: true,
});

If you want things to scroll regardless of the count, you could try setting infinite: true .如果您希望无论计数如何滚动,您都可以尝试设置infinite: true

set slidesToShow: 2.99 这就是我的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM