Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android browser setting element size too small

I have a website using the meta tag <meta name="viewport" content="width=device-width, target-densityDpi=device-dpi">, Javascript that formats the css for body to screen width and height, and elements inside that have percentage-based widths.

On desktop, this works fine. On my Android phone and tablet's browsers, though, the content isn't scaling properly - everything is just a little too small, and double-tapping to zoom zooms in to the right size (while not displaying the entire page width). This happens both in portrait and landscape mode, and the zoom level appears to be identical, or at least similar.

I have an alert come up telling me what the javascript has formatted body width and height to, and it is always right, but the browser feels the need to load as though the size of the window was actually larger.

I understand there's some nonsense where browsers get confused between CSS pixels and real pixels, but I thought the meta tag there was supposed to fix all of that.

So how do I make the browser load the page to a real 100% screen size, and not some sort of ~125% size?

like image 357
Flickerdart Avatar asked Nov 13 '22 23:11

Flickerdart


1 Answers

Add

user-scalable=no

to your viewport meta-tag, this (at least in my tests) forces the browser to display at the width specified instead of the user/browsers preference.

like image 172
Oli B Avatar answered Nov 15 '22 13:11

Oli B