Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical align content slickslider

I've been struggling to get my content vertical aligned but really don't fix it. I tried the adaptiveHeight parameter but it really didn't do what I wanted.

Fiddle: http://jsfiddle.net/fmo50w7n/400

This is what the code looks like HTML:

<section class="slider">
    <div style="width:500px;height:200px">slide1</div>
    <div style="width:500px;height:300px;">slide2</div>
    <div style="width:500px;height:100px;">slide3</div>
</section>

CSS:

$c1: #3a8999;
$c2: #e84a69;

.slider {
    width: auto;
    margin: 30px 50px 50px;
}

.slick-slide {
    background: $c1;
    color: white;
    padding: 40px 0;
    font-size: 30px;
    font-family: "Arial", "Helvetica";
    text-align: center;
}

.slick-prev:before, 
.slick-next:before {
    color: black;    
}

.slick-dots {
    bottom: -30px;
}


.slick-slide:nth-child(odd) {
     background: $c2;
}

JS:

$(".slider").slick({
    autoplay: true,
    dots: true,
    variableWidth:true,
    responsive: [{ 
        breakpoint: 500,
        settings: {
            dots: false,
            arrows: false,
            infinite: false,
            slidesToShow: 2,
            slidesToScroll: 2
        } 
    }]
});
like image 352
Sandro Avatar asked May 26 '16 08:05

Sandro


1 Answers

This solution works for me:

.slick-track {
  display: flex;
}
.slick-track .slick-slide {
  display: flex;
  height: auto;
  align-items: center;
  justify-content: center;
}

See example here:

https://codepen.io/leggomuhgreggo/pen/mEmzGN

like image 132
Simon Avatar answered Oct 01 '22 02:10

Simon