Modify the viewport based on screen width

The following snippet will cause mobile browsers to zoom in 320px of content. Useful for responsive design with fixed widths at the various breakpoints. Depends on JQuery.

<script>
    if ($(window).width() <= 640) {
        $('meta[name=viewport]').attr('content','width=320, user-scalable=1');
    }
</script>

Comments are closed here.