I have a fixed webpage width (640 pixels wide). I would like this page to shrink to the width of the mobile device. However, if the native width of the device is more than 640 pixels, I donβt want it to stretch. Seems simple enough:
<meta name="viewport" content="width=640, maximum-scale=1.0" />
This works as expected on an iPad / iPhone. However, on an Android tablet (for example, in landscape mode), the content becomes scaled to fit the display. In other words, Android simply ignores max-scale = 1. You can see the example page with the problem here . For completeness, here is the source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Viewport</title> <meta name="viewport" content="width=640, maximum-scale=1.0" /> <style> div.bar { position: absolute; width: 636px; height: 50px; background-color: yellow; border: 2px solid black; left: 50%; margin-left: -320px; } </style> </head> <body> <div class="bar"> </div> </body> </html>
I experimented a lot and experimented with viewport meta tags. I read almost everything on this topic, but did not see this seemingly basic problem.
Two notes:
This is not a problem with a given dpi density
Setting the width of the viewport to the width of the device is not useful in this case, since the width of the content is fixed and greater than (for example) the width of the phoneβs portfolio. If I set width = device width, the page will not be automatically reduced to fit the phone.
Many thanks.
logidelic
source share