Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable zoom on mobile devices for fixed viewport size

Tags:

html

css

I am trying to disable zoom on mobile devices. I know this code will work.

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

But in my case, i have not the option to use "width=device-width". I have to set the viewport size to 480px so i am using the following code

<meta name="viewport" content="width=480px, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

But i get a zoomed in view of the page on mobile device and i am able to zoom it out.

like image 380
Awais Umar Avatar asked Jul 21 '14 08:07

Awais Umar


1 Answers

Using "target-densitydpi=device-dpi" and hence the code

<meta name="viewport" content="width=480, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no" />

fixed my problem. Thanks to Dave Rook

like image 87
Awais Umar Avatar answered Oct 17 '22 10:10

Awais Umar