I saw the code write this in mixins.helpers.initialize and line 30
var slideWidth = trackWidth / props.slidesToShow;
But i want add margin or padding on slidesItem rather than each mixed together
like this:
var slideWidth = (trackWidth+padding*2) / props.slidesToShow;
I saw the examples,every slides item not mixed together.
and however i can use css like padding:0 10px; to resolve it
Is there any options to set it?
Using css is the best way to control margin/padding on slides
@V-Tom Did you ever happen to find a good solution to this? Like @akiran says you can set margin or padding on the slides, but the next slide and previous slide button don't respect that and end up not left-aligning the slides with the start of the carousel.
My workaround around this issue was to wrap my slides with an additional <div/> which has a padding-right set for the amount of desired margin:
{
centerMode: true,
slidesToShow: 1,
slidesToScroll: 1,
centerPadding: 30
}
<div className="item">
<SlideElement>...</SlideElement>
</div>
.item {
padding-right: 10px;
}
A solution that worked well for our team was to add a thick border to each item that is the same color as the background. This way the padding doesn't affect the carousel in any way.
@mcmillhj-wta That worked really well for me as well, in combination with setting the box-sizing property to "border-box".
What did work for me, is this:
I wrapped my item with a container that have height bigger than the item itself, and then I deleted the margin from my item ;)
I fixed it using
.slick-slide {
padding: 0 15px;
}
.slick-list {
margin: 0 2em;
}
I ended up adding margin to the element inside ..slick-slide and then add negative margin on .slick-list
e.g.
.slick-slide img {margin-left:10px;}
.slick-list {margin-left:-10px;}
You dont need to set margins just set:
.slick-slide {
padding: 0 8px;
box-sizing: border-box;
}
padding-left/right depends on your centerPadding.
I fixed it using
.slick-slide { padding: 0 15px; } .slick-list { margin: 0 2em; }
many thanks, it worked in my case!
Most helpful comment
I fixed it using