Skip to content

Instantly share code, notes, and snippets.

@girvan
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save girvan/9317639 to your computer and use it in GitHub Desktop.
Save girvan/9317639 to your computer and use it in GitHub Desktop.
<meta name="viewport" id="viewport" />
<script>
var viewport_width = 400;
(function(target_width){
var device_width = screen.width || 320,
ratio = (device_width/target_width);
// desktop or some old mobile browser
if(device_width > 414 || device_width < 320)
ratio = 1.0;
document.getElementById('viewport').content = "width=device-width,user-scalable=1,initial-scale=" + ratio;
})(viewport_width);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment