Last active
August 29, 2015 14:06
-
-
Save mherchel/70b25db7dca7c44f5956 to your computer and use it in GitHub Desktop.
Equal Heights Flexbox Fallback
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
/** | |
* Set divs to equal heights. | |
*/ | |
function equalheight(selector, bypassCheck) { | |
if (($(window).width() > 720) && ((bypassCheck == 1) || !(Modernizr.flexbox) || !(Modernizr.flexboxlegacy))) { | |
var maxHeight = 0; | |
$(selector).each(function(){ | |
if ($(this).height() > maxHeight) { | |
maxHeight = $(this).height(); | |
} | |
}); | |
$(selector).height(maxHeight); | |
} | |
} | |
$(window).resize(function() { | |
equalheight("#mini-panel-home_page_get_involved > div > div", 0); | |
equalheight(".pane-article-list-featured-articles .view-content > ul > li", 0); | |
equalheight(".project-teaser", 1); // Flexbox cannot work in this case, so add a bypassCheck = 1 | |
}); | |
$(window).load(function() { | |
equalheight("#mini-panel-home_page_get_involved > div > div", 0); | |
equalheight(".pane-article-list-featured-articles .view-content > ul > li", 0); | |
equalheight(".project-teaser", 1); // Flexbox cannot work in this case, so add a bypassCheck = 1 | |
}); |
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
/** | |
* Use flexbox for equal heights when available. | |
*/ | |
#mini-panel-home_page_get_involved { | |
@include breakpoint($breakpoint-medium) { | |
// Insert non-flexbox legacy css here | |
.flexboxlegacy & { // IE10 | |
display: -ms-flexbox; | |
} | |
.flexbox & { | |
display: flex; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment