Last active
May 21, 2019 17:17
-
-
Save jgram925/3766ad3b195377cf3abcf623e15f72c8 to your computer and use it in GitHub Desktop.
Bootstrap Equal Columns.js
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
# Instantiated | |
function panelHeight(indexStart, greaterIndex){ | |
if($(window).width() > 975){ | |
var tallestHeight = 0; | |
for(i=indexStart; i<greaterIndex; i++){ | |
var testHeight = $(".panel-body:eq(" + i + ")").outerHeight(); | |
if(testHeight > tallestHeight){ | |
tallestHeight = testHeight; | |
}; | |
}; | |
var setHeight = $(".panel-body:lt(" + greaterIndex + ")").css("min-height", tallestHeight); | |
}; | |
}; | |
$(window).on("load resize", function(){ | |
// Removes min-height on resize, load and sets it again. | |
$(".panel-body").css("min-height", "0"); | |
// Bottom first, or it overwrites top. | |
// Second argument is one greater than object index. | |
panelHeight(3, 6); | |
panelHeight(0, 3); | |
}); | |
# CSS Class | |
function panelHeight() { | |
$('.sameHeight').each(function(){ | |
var row_cols = $(".panel", this); | |
if($(window).width() > 975){ | |
var heights = row_cols.map(function(){ | |
return $(this).height(); | |
}); | |
maxHeight = Math.max.apply(null, heights); | |
row_cols.each(function(){ | |
$(this).css('min-height', maxHeight); | |
}); | |
}; | |
}); | |
}; | |
$(window).on("load resize", function(){ | |
$(".panel").css("min-height", "0"); | |
panelHeight(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment