Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Last active December 24, 2018 11:56
Show Gist options
  • Save Farmatique/f277e584188440aae56421ab477a30e1 to your computer and use it in GitHub Desktop.
Save Farmatique/f277e584188440aae56421ab477a30e1 to your computer and use it in GitHub Desktop.
Equalize or set the height of block to fit maximum height in set of blocks
function matchHeight(wrapperEl, matchEl){
var maxHeight = 0;
var element = jQuery(wrapperEl);
jQuery(element).find(matchEl).each(function(index, element){
// reset previous min-height
jQuery(this).css('min-height', 0);
if (jQuery(this).outerHeight() > maxHeight) { maxHeight = jQuery(this).outerHeight(); }
});
jQuery(element).find(matchEl).css('min-height', maxHeight);
}
//apply function on load and resize
jQuery(window).on('load resize', function(){
matchHeight('.pro-section', '.pro-section-single');
matchHeight('.whycrown-section_blocks', '.whycrown-section-block');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment