Last active
January 30, 2019 18:55
-
-
Save stripedpurple/4ce7a7d801aa9b9a410da2cf493ff301 to your computer and use it in GitHub Desktop.
Simple jquery plugin for creating equal height columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Demo here ---> https://codepen.io/VCOBA/pen/VWGNgQ | |
*/ | |
// Equal Height Columns | |
function handleEqualHeight() { | |
var EqualHeightColumns = function () { | |
$('.eq-h-row').each(function () { | |
heights = []; | |
$('.eq-h-col', this).each(function () { | |
$(this).removeAttr('style'); | |
heights.push($(this).height()); // Write column's heights to the array | |
}); | |
$('.eq-h-col', this).height(Math.max.apply(Math, heights)); // Find and set max | |
}); | |
}; | |
EqualHeightColumns(); | |
$(window).resize(function () { | |
EqualHeightColumns(); | |
}); | |
$(window).on('load', function () { | |
EqualHeightColumns(); | |
}); | |
// use with jQuery <= 1.8 | |
// $(window).load(function () { | |
// EqualHeightColumns(); | |
// }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo