Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Forked from JKirchartz/windowResizeHeight.js
Created December 13, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/1cb2e84bf1352037c122932885b91bc4 to your computer and use it in GitHub Desktop.
Save tomhodgins/1cb2e84bf1352037c122932885b91bc4 to your computer and use it in GitHub Desktop.
If I have to write bad code to get the "right" design, so be it, but at least I can keep it D.R.Y. -- This snippet listens to window sizing commands, internally the sameHeight functions take a container class and a child's class, find the tallest child, then makes all that containers children the same height -- this is only for when CSS's `flexb…
$(window).resize(function(){
function sameHeight(container, child) {
$(container).each(function(){
var tallest = 0;
$(child, this).each(function(){
if($(this).height() > tallest) {
tallest = $(this).height();
}
});
$(child, this).height(tallest);
});
}
sameHeight('.callout.cost', '.cost-box');
sameHeight('.callout.give', '.give-box');
}).resize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment