Set Equal Heights Based on Tallest [Snippet] <> No-Code Supply Co.

Set Equal Heights Based on Tallest

Set Equal Heights Based on Tallest
// Add the attribute of data-match-height="groupName" to all elements you want to match height
var matchHeight = function () {
function init() {
eventListeners();
matchHeight();
}
function eventListeners(){
$(window).on('resize', function() {
matchHeight();
});
}
function matchHeight(){
var groupName = $('[data-match-height]');
var groupHeights = [];
groupName.css('min-height', 'auto');
groupName.each(function() {
groupHeights.push($(this).outerHeight());
});
var maxHeight = Math.max.apply(null, groupHeights);
groupName.css('min-height', maxHeight);
};
return {
init: init
};
} ();
$(function() {
matchHeight.init();
});

Force the height of separate elements to be the same based on whichever of them is the tallest. This is helpful for a tabs component with varying heights of content in each tab, which causes the page to jump when changing tabs. Learn more here: https://codepen.io/Lewitje/pen/YybQEP

Creators

Have feedback or a question related to this item? Drop us some feedback!

Curated: 
1.11.21

Similar items

Rune

8.1.24

Blok

8.1.24

Sophia Amoruso

8.1.24

Unset Studio

8.1.24

Fetch

7.31.24
Featured
Preview

Osmo

View item

tinyPod

7.31.24

Ultimate Notion Icons

$49
7.31.24

Faith of a Mustard Seed

7.30.24

Runway AI: Ambient Intelligence

7.30.24

Retronova

7.30.24

Renewed Vision

7.30.24

Public Work

7.30.24

Lobato

7.27.24

OVERLAY

7.25.24

Stewart & Partners

7.25.24

Jamm

7.25.24

Botanic Expo

7.25.24

SUPER GIANT

7.25.24

Defijn

7.25.24

Isle of Skye Whisky

7.25.24

Chrono

7.23.24

mmm

7.23.24

Jordan Gilroy

7.23.24

Templace

7.22.24

Brandfetch

7.22.24
Load more

Bummer, no results

Try a different search/filter combo, or drop us some feedback if there is something missing you would love to see!

Reset filters

Subscribe for updates

Get updates on the latest curated resources and be the first to hear of new features.