I have a web app where responsive layout is not an option for mobile devices, so I tried playing with the viewport scaling a bit but had no success in doing so.
Page size is 1280x720 so on small screens it should be zoom out and on larger ones zoomed in:
var scale = $(window).width() / 1280;
$('head').append('<meta name="viewport" content="width=device-width, height=device-height, initial-scale=' + scale + ', maximum-scale=' + scale + ', user-scalable=0">');
I've only tried this for width but the result is not the desired one, am I doing something wrong?
There are different ways of designing a responsive website.
CSS Media Query.
View port.
Calculate width dynamically using
window.innerWidth & window.outerWidth
properties.For me I create a css-layout file link it to my html file and query every width or you could learn bootstrap and your site will be mobile ready without doing what I do (bootstrap is a pain to edit js for me) As far as querying this is how I write it out
in your html
then in your css
I would just write it out however you want your css for your webpage then build the dimensions like what is shown above also lets say you wanted an menu bar to appear you can create a css for the main nav then use @media then change the css for that nav to make the menu bars appear.
also
and
Are really helpful when querying
Applying bootstrap.
Try to use col-xs (col-xs-4 to col-xs-12) to all your div classes and give your elements a fixed width/height using css media queries.
When I tried this out using Chrome's devTools, the
scale
variable appeared to be about double the correct amount. Dividing by 2 fixed the issue for me:I am not sure exactly what you are trying to achieve, but with the following html
and the following JS
you should be able to show the page initial zoomed in or out on mobile devices. You would have to check the device was in portrait. For landscape you would need to use screen.height as opposed to screen.width