Tablet's scaling my web page by 1.5x causing layout issues

空扰寡人 提交于 2019-12-08 05:12:55

问题


So I have a web app that looks perfectly fine at 1024x768 pixels on a laptop (I really don't care about phone at the moment). However, when I take the same app onto a tablet it doesn't fit even though the pixel availability is way higher than 1024x768. It turns out that the tablets are scaling my app so it uses a 1.5 x css pixel multiplier causing it to be much larger on the tablets.

I have the following in my html head:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

But it still scales the web page. This code seems to me that it would set the initial scale to 1.0 so that css pixels == hardware pixels, but it doesn't. I'm not really in a place to use full responsive design for this. I just need to have tablets stop scaling my values for me. How can I get this fixed?


回答1:


I believe this is what you might be looking for

body * {-webkit-text-size-adjust: 100%; }

read here for the documentations https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust




回答2:


You're falling victim to the CSS pixel ratio: http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density of your device. Each device has a scaling factor applied to css. For example, the ipad mini is a ratio of 2.

There are ways to query the ratio in CSS, but it is not recommended according to Mozilla.

https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries#-moz-device-pixel-ratio

 @media (-webkit-min-device-pixel-ratio: 2), /* Webkit-based browsers */
   (min--moz-device-pixel-ratio: 2),    /* Older Firefox browsers (prior to Firefox 16) */
   (min-resolution: 2dppx),             /* The standard way */
   (min-resolution: 192dpi)             /* dppx fallback */ 


来源:https://stackoverflow.com/questions/24617792/tablets-scaling-my-web-page-by-1-5x-causing-layout-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!