Created
December 3, 2016 14:06
-
-
Save techjewel/d6d1797b4a485a2b7621d76500d8ba0a to your computer and use it in GitHub Desktop.
Make Children divs as equal height with js
This file contains hidden or 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
var doEqualHeights = function (parentNodeSelector, childNodeSelector) { | |
var $nodes = $(parentNodeSelector); | |
$.each($nodes, function (index,node) { | |
var children = $(node).find(childNodeSelector); | |
var childHeight = 0; | |
$.each(children, function (index, child) { | |
var currentHeight = $(child).height(); | |
if(currentHeight > childHeight) { | |
childHeight = currentHeight; | |
} | |
}); | |
children.css('height', childHeight+'px'); | |
}); | |
}; | |
// usage | |
doEqualHeights('.equal_height', '.child_section'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two lines of code in CSS. :P
parent {
display: flex;
flex-direction: row;
}