简体   繁体   English

如何使我的SlickJS Carousal在3张图像之间循环,并在循环时将它们全部可见?

[英]How can I get my SlickJS Carousal to cycle between 3 images and have them all visible while cycling?

I am using SlickJS to build a slider that will allow me to cycle between images. 我正在使用SlickJS构建一个滑块,使我可以在图像之间循环。

Similar to this image 与此图像相似

Link to SlickJS Documentation 链接到SlickJS文档

There area a couple of problems that I am running into. 我遇到了一些问题。

The first is that, as far as I know, you cannot cycle between images if you are showing them all at once. 首先,据我所知,如果一次显示所有图像,则无法在图像之间循环。 For example if you set slidesToShow to 3 and you have only 3 images, you cannot cycle through them. 例如,如果将slidesToShow设置为3,而只有3张图像,则无法循环浏览它们。

The other problem I have is that even when assigning custom buttons and running the slickNext and slickPrev functions through them, it still does not cycle. 我的另一个问题是,即使分配自定义按钮并通过它们运行slickNextslickPrev函数,它仍然不会循环。

Could anyone provide me guidance on how to get the slider to function similar to the image I provided above? 谁能为我提供有关如何使滑块发挥与以上提供的图像相似功能的指导?

Here is the code I have: 这是我的代码:

 <div>
    <button class="left-selector" style="height: 20px; width: 20px">
    </button>
    <div class="center-ag-slider">
        <div>
            <img style="max-width:100%; max-height:100%;" src="https://keystonepuppies.com/wp-content/uploads/2012/11/Siberian-Husky-Category-950x700.jpg">
        </div>
        <div>
            <img style="max-width:100%; max-height:100%;" src="https://dgicdplf3pvka.cloudfront.net/2355971/siberian-husky-puppy-picture-473f7308-f278-4858-b1ec-81368845e1be.jpg">
        </div>
        <div>
            <img style="max-width:100%; max-height:100%;" src="https://i.ebayimg.com/00/s/NzUzWDEwMjQ=/z/bCwAAOSwTM5YtzZy/%24_86.JPG">
        </div>

    </div>
    <button class="right-selector" style="height: 20px; width: 20px">
    </button>
</div>

<script type="text/javascript">

        $(document).ready(function () {

            $('.center-ag-slider').slick({
                centerMode: true,
                centerPadding: '60px',
                slidesToShow: 3,
                initialSlide: 0,
                responsive: [
                    {
                        breakpoint: 768,
                        settings: {
                            arrows: false,
                            centerMode: true,
                            centerPadding: '40px',
                            slidesToShow: 3
                        }
                    },
                    {
                        breakpoint: 480,
                        settings: {
                            arrows: false,
                            centerMode: true,
                            centerPadding: '40px',
                            slidesToShow: 1
                        }
                    }
                ]
            });

            $('.left-selector').click(function () {
                $(".center-ag-slider").slick("slickPrev");
            });
            $('.right-selector').click(function () {
                $(".center-ag-slider").slick("slickNext");
            });

        });
    </script>

You can set a width on the slick-slide class in css that will display them all on the page simultaneously. 您可以在css中的slick-slide类上设置宽度,以同时在页面上全部显示它们。 So, in this case because there are 3 images you are trying to slide through you would set the width on slick-slide to be 33.333333%; 所以,在这种情况下,因为有你试图通过滑动你会设置宽度3的图像, slick-slide是33.333333%;

.slick-slide {
  width: 33.333333%;
}

暂无
暂无

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

相关问题 如何获得不同的图像和文本以自动循环显示? 我的图像正在循环,但我的文本不是 - How do I get different images and text to cycle through automatically? My images are cycling, but my text isn't 我如何获取所有行车方式(例如行车,公交,骑车,步行)的距离和时长,并将其存储在数据库中 - how can i get distance and duration for all travel modes like driving,transit,cycling,walking in my page,and storing the same in db 如何在香草 javascript 中制作我的图像旋转循环? - How can i make my image carousal loop in vanilla javascript? 为什么我的图像在打开检查工具之前无法加载到 carousal 中? - why my images not load in carousal untill i open inspect tool? 我有很多数据自我元素,但是我怎么能得到所有这些? - i have many data-self element, but how can i get all of them? 在它们之间单击时,如何让我的搜索框选项卡保持活动状态? - How can I get my search box tabs to remain active when clicking between them? 循环时如何继续? - How can i continue while cycle? 如何获取输入的所有值并将它们放在我的对象(localStorage)中的正确位置? - How can I get all the values ​of the inputs and put them in the right place in my object (localStorage)? 如何从我的 nasa api 获取所有图像 url 并将它们添加到图像滑块中 - How can i get all image urls from my nasa api and add them into an image slider 出于某种原因,我的所有标签都被视为一个。 我怎样才能让他们分开? - for some reason all my tabs are considered as one. how can i get them to be separate?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM