Created
April 24, 2017 13:34
Star
You must be signed in to star a gist
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
// 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