What I want is to have a slider that shows 3.5 slides at once, with the right most slide being the one that is only half shown. I have seen something like this done successfully using centerMode and centerPadding with slick slider, but I do not want the slides to be centered. In other words, I want the left most slide to be flush with the side of the window, totally in view, but the right most slide to be half in the window, half off. Is this possible in slick? I've seen people using slidesToShow: 3.5, but this makes the left most slide go half off the screen and I need it on the right.
No need to add "slidesToShow: 3.5 option"
Just call slick:-
$('.Your-container').slick({
arrows: false,
});
and add following CSS:
.slick-list{padding:0 20% 0 0 !important;}
Either you can give a fixed padding to the right or percentage.
.slick-list{padding:0 20% 0 0 !important;}
worked for me. As slick functionalityit self add padding:0;
to the .slick-list
class that overwrites our css. –
Cabal You can do something like this slidesToShow: 3.5
and make infinite: false
. The right most slide will be showing half.
infinite: false
does the trick, been banging my head on this for a while! –
Shetler You can also do this in slick by adding these two parameters in the slick init:
centerMode: true,
centerPadding: '20%',
This is the equivalent to
.slick-list{padding:0 20% 0 0;}
Please beware of using slidesToShow
with decimal places.
According to Official Documentation slidesToShow
is of type int
and not float
.
Using it as float is causing unpredictable exceptions on breakpoint
event (when you have custom breakpoint option specified).
You can read more about those issue in official Slick GitHub threads here, here.
slidesToShow
is of type int –
Tivoli Maybe need to add important in CSS.
Here is my JS code:
$(this).slick({
slidesToShow: 1,
slidesToScroll: 1,
adaptiveHeight: true,
infinite: true,
arrows: true,
dots: false,
centerMode: true,
})
Here is CSS code:
.slick-list {
padding:0 20% 0 0 !important;
}
My use case is a bit different since I want to show portions of both the previous and next slides, as well as the arrows between the current slide and those slides.
What's working for me so far is adding these styles:
.slick-list {
/* Show slides that would otherwise be hidden off-screen */
overflow: visible;
}
.slick-slide:not(.slick-current) {
/* Make slides other than the current one translucent */
opacity: 0.4;
}
It's a work-in-progress, but this was the only way I could find to show previous of both the previous and next slides.
Might be worth noting that the setting lazyLoad: "ondemand"
is incompatible with this approach, as the preview slides' content won't be loaded until they're in the center.
© 2022 - 2024 — McMap. All rights reserved.