Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Last active August 29, 2015 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/b7973bfc3eda69b986ee to your computer and use it in GitHub Desktop.
Save EdCharbeneau/b7973bfc3eda69b986ee to your computer and use it in GitHub Desktop.
IE10 Mobile viewport fix
<!-- 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