Skip to content

Instantly share code, notes, and snippets.

@jpdery
Created April 24, 2017 13:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jpdery/40ae985c43b2168b7869f70ca0e5aab3 to your computer and use it in GitHub Desktop.
// IE 11 Min Height Flex Fix
if (window.navigator.userAgent.indexOf('Trident/7.0') > 0 ||
window.navigator.userAgent.indexOf('Trident/6.0') > 0) (function($) {
$('*:not(.no-ie-flex-fix').each(function(i, element) {
element = $(element)
var timeout = null
var display = element.css('display')
var minimum = parseInt(element.css('min-height'))
if ((display === 'flex' || display === '-ms-flexbox') && minimum > 0) {
var measure = function() {
var minimum = parseInt(element.css('min-height'))
if (minimum > 0) {
element.css('height', '')
var height = element.get(0).scrollHeight
if (height < minimum) {
height = minimum
}
console.log('Setting height to', height)
element.css('height', height)
} else {
element.css('height', '')
}
timeout = null
}
$(window).on('resize', function() {
if (timeout == null) {
timeout = setTimeout(measure, 16)
}
})
measure()
}
})
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment