Skip to content

Instantly share code, notes, and snippets.

@techjewel
Created December 3, 2016 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techjewel/d6d1797b4a485a2b7621d76500d8ba0a to your computer and use it in GitHub Desktop.
Save techjewel/d6d1797b4a485a2b7621d76500d8ba0a to your computer and use it in GitHub Desktop.
Make Children divs as equal height with js
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');
@mahmud2011
Copy link

Two lines of code in CSS. :P

parent {
display: flex;
flex-direction: row;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment