Skip to content

Instantly share code, notes, and snippets.

@JKirchartz
Last active December 13, 2016 15:53
Show Gist options
  • Save JKirchartz/83b29ba21a8b39df4146db28eb8ac0b3 to your computer and use it in GitHub Desktop.
Save JKirchartz/83b29ba21a8b39df4146db28eb8ac0b3 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