Tag: Auto Height

Automatic adjust element height based on the tallest element

It will loop all elements based on class and adjust the height based on the tallest element. HTML Code jQuery Code $(window).resize(function(){ initArticleBox(“.box”); }); $(window).load(function(){ initArticleBox(“.box”); }); function initArticleBox(selector){ var box = $(selector) box.height(“auto”); if ($(window).width() > 768){ var maxHeight = 0; var article = box.each(function(){ maxHeight = Math.max(maxHeight, jQuery(this).height()); }).height(maxHeight);; }else{ box.height(“auto”); } }

Read more