How can I change the width and height of slides on Slick Carousel?
Basically you need to edit the JS and add (in this case, inside $('#featured-articles').slick({
), this:
variableWidth: true,
This will allow you to edit the width in your CSS where you can, generically use:
.slick-slide {
width: 100%;
}
or in this case:
.featured {
width: 100%;
}
I made this plugin. There is some css interference taking place.
It's your border on the slider itself. Either use
box-sizing: border-box
to absorb the border width, or put the border on the content inside the slide.
I initialised the slider with one of the properties as
variableWidth: true
then i could set the width of the slides to anything i wanted in CSS with:
.slick-slide {
width: 200px;
}
I found good solution myself. Since slick slider is still used nowadays i'll post my approach.
@RuivBoas answer is partly correct. - It can change the width of the slide but it can break the slider. Why?
Slick slider may exceed browser width. Actual container width is set to value that can accomodate all it's slides.
The best solution for setting slide width is to use width of the actual browser window. It works best with responsive design.
For example 2 slides with absorbed width
CSS
.slick-slide {
width: 50vw;
// for absorbing width from @Ken Wheeler answer
box-sizing: border-box;
}
JS
$(document).on('ready', function () {
$("#container").slick({
variableWidth: true,
slidesToShow: 2,
slidesToScroll: 2
});
});
HTML markup
<div id="container">
<div><img/></div>
<div><img/></div>
<div><img/></div>
</div>