Created
December 11, 2012 08:36
-
-
Save bigfive/4256993 to your computer and use it in GitHub Desktop.
Change viewport initial scale and width depending on device width
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
changeViewportMeta = function() { | |
$('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=1, maximum-scale=1.3, width=device-width'); | |
if ($(window).width() <= 320) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.63, maximum-scale=1.3, width=480'); | |
} else if ($(window).width() <= 480) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.89, maximum-scale=1.3, width=480'); | |
} else if ($(window).width() <= 768) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.8, maximum-scale=1.3, width=920'); | |
} else if ($(window).width() <= 1024) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.85, maximum-scale=1.3, width=920'); | |
} | |
}; | |
$(window).bind('orientationchange', changeViewportMeta) | |
$(document).ready(function() { | |
changeViewportMeta(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bigfive