Front-End & Daily

[slick.js] Sample of the 'adaptiveHeight' option to make the slider height variable for each slide

[slick.js] Sample of the 'adaptiveHeight' option to make the slider height variable for each slide

Introducing a sample of the 'adaptiveHeight' option for the jQuery slider plugin "slick.js", which adjusts the slider's height to the current slide when image sizes (heights) vary.

Here's how to equalize the heights of slides that vary.

Sample

I have prepared images with varying heights.

You will notice that the slider's height changes to match the height of the current slide.

HTML

We will create a very standard slick slider.

<div class="slider">
	<div class="slide"><img src="img01.jpg"></div>
	<div class="slide"><img src="img02.jpg"></div>
	<div class="slide"><img src="img03.jpg"></div>
	<div class="slide"><img src="img04.jpg"></div>
</div>

JS

The JS looks like this.

$(".slider").slick({
	centerMode: true, //Optional
	variableWidth: true, //Optional
	adaptiveHeight: true, //Make slider height variable
});

You can set this by adding 'adaptiveHeight: true' on line 5.

You can also fix the height of the pager

Of course, you can also fix the height of the left and right pagers.

It's hard to click the pager if its position changes every time you move the slide, isn't it?

Comments

We also welcome reports such as 'It worked!'

After reviewing the content, we will publish it, omitting any personal information.

Enter your name and email address

Please enter if you would like a reply via email.

Personal information provided will not be disclosed. It will only be used for replies.

It will be sent directly. Please confirm and click 'Send'.

If this was helpful, we appreciate your support!
All support received will go toward my child’s upbringing.

Author's Baby Registry (Amazon)

Support me via OFUSE

Alternatively, support me by purchasing something through the buttons below
(You don't have to buy the specific item linked.)

Support me via Amazon

Support me via Rakuten

Support me via Yahoo!Shopping

PR

As an Amazon Associate, Ken earns from qualifying purchases.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark