Skip to content

Instantly share code, notes, and snippets.

@stripedpurple
Last active January 30, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripedpurple/4ce7a7d801aa9b9a410da2cf493ff301 to your computer and use it in GitHub Desktop.
Save stripedpurple/4ce7a7d801aa9b9a410da2cf493ff301 to your computer and use it in GitHub Desktop.
Simple jquery plugin for creating equal height columns
/*
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();
// });
}
@stripedpurple
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment