Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slick carousel - force slides to have the same height

I'm having trouble with the Slick carousel JS plugin with multiple slidesToShow which have different heights.

I need the Slides to have the same height, but with CSS flex-box it doesn't work as the slides have conflicting CSS definitions.

Also, I didn't find anything useful in the forums and on the web.

HTML

<div class="slider">   <div class="slide">     <p>Lorem ipsum.</p>   </div>   <div class="slide">     <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua</p>   </div>   <div class="slide">     <p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>   </div>   <div class="slide">     <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>   </div> </div> 

JS

$('.slider') .slick({     autoplay: false,     dots: false,     infinite: false,     arrows: false,     slidesToShow: 2,     slidesToScroll: 2,     rows: 0 }); 

CSS

.slide {   height: 100%;   background-color: #ccc;   padding: 10px; } 
like image 572
JJaun Avatar asked Feb 28 '18 11:02

JJaun


People also ask

How do you use slick slider Codepen?

You can also link to another Pen here (use the . css URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.

What is a slick slide?

A slideshow component for cycling through elements—images or slides of text—like a carousel.


1 Answers

Add a couple of CSS styles and it will be ready:

.slick-track {     display: flex !important; }  .slick-slide {     height: inherit !important; } 

Enjoy! :-)

like image 70
Phoenix Avatar answered Sep 25 '22 12:09

Phoenix