I want to add space between two slick carousel items, but not want the space with padding, because it\'s reducing my element size(and I don\'t want that).
The slick-slide has inner wrapping div which you can use to create spacing between slides without breaking the design:
.slick-list {margin: 0 -5px;}
.slick-slide>div {padding: 0 5px;}
An improvement based on the post by Dishan TD (which removes the vertical margin as well):
.slick-slide{
margin-left: 15px;
margin-right: 15px;
}
.slick-list {
margin-left: -15px;
margin-right: -15px;
pointer-events: none;
}
Note: the pointer-events was necessary in my case, to be able to click on the left arrow.
For example: Add this data-attr to your primary slick div: data-space="7"
$('[data-space]').each(function () {
var $this = $(this),
$space = $this.attr('data-space');
$('.slick-slide').css({
marginLeft: $space + 'px',
marginRight: $space + 'px'
});
$('.slick-list').css({
marginLeft: -$space + 'px',
marginRight: -$space/2 + 'px'
})
});
Yup, I have found the solution for dis issue.
/* the slides */
.slick-slide {
margin: 0 27px;
}
/* the parent */
.slick-list {
margin: 0 -27px;
}
This problem reported as issue (#582) on plugin's github, btw this solution mentioned there too, (https://github.com/kenwheeler/slick/issues/582)
Just fix css:
/* the slides */
.slick-slider {
overflow: hidden;
}
/* the parent */
.slick-list {
margin: 0 -9px;
}
/* item */
.item{
padding: 0 9px;
}