Last active
August 29, 2015 14:09
-
-
Save EdCharbeneau/b7973bfc3eda69b986ee to your computer and use it in GitHub Desktop.
IE10 Mobile viewport fix
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
<!-- Windows Phone 8 and Internet Explorer 10 | |
Internet Explorer 10 doesn't differentiate device width from viewport width, | |
and thus doesn't properly apply the media queries in Bootstrap's CSS. | |
To address this, you can optionally include the following CSS and JavaScript | |
to work around this problem until Microsoft issues a fix. | |
Attribution: overflow http://stackoverflow.com/questions/19659053/viewport-for-ie10-11-desktop-but-not-mobile | |
--> | |
<style> | |
@-webkit-viewport { width: device-width; } | |
@-moz-viewport { width: device-width; } | |
@-ms-viewport { width: device-width; } | |
@-o-viewport { width: device-width; } | |
@viewport { width: device-width; } | |
</style> | |
<script> | |
if (navigator.userAgent.match(/IEMobile\/10\.0/)) { | |
var msViewportStyle = document.createElement("style") | |
msViewportStyle.appendChild( | |
document.createTextNode( | |
"@-ms-viewport{width:auto!important}" | |
) | |
) | |
document.getElementsByTagName("head")[0].appendChild(msViewportStyle) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment