Last active
October 12, 2016 08:49
-
-
Save filipecsweb/9c3649c7c8e4f8ed3d3e to your computer and use it in GitHub Desktop.
Forcing the same height to specific elements
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
/** | |
* Define parameters to set 'where' and what 'element' will have same height. | |
* | |
* @author Filipe Seabra | |
* @param where element's father | |
* @param element selector of the elements that must have same height | |
*/ | |
jQuery(window).load(function(){ | |
function sameHeight(where, element){ | |
var height = []; | |
var maxHeight = 0; | |
jQuery(where).find(element).each(function(index){ | |
height[index] = jQuery(this).height(); | |
if(height[index] > maxHeight){ | |
maxHeight = height[index]; | |
} | |
}).css('min-height', maxHeight); | |
} | |
sameHeight('.where', 'div.element'); // Just an example | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment