开发者

Android 2.2 2.3 workaround for device-width media query

I've observed a problem on Android 2.2 and 2.3 native browser where device-width CSS media query and window.screen.width both report sizes based on your webpage document and scaling applied.

Example: 1:1 scaling, 960px wide page will show proper device width开发者_运维百科 (say, 320px)

Example: fit-screen scaling, 960px wide page, improperly reports 960px device width

So with appropriate viewport meta tag content it seems predictable. However, in my case I cannot rely on the meta tag. Does anyone use a workaround to get a reliable device width measurement in Android irrespective of viewport meta tag? Other platforms do report this correctly across all scaling.

Ref: http://code.google.com/p/android/issues/detail?id=11961


window.outerWidth and window.outerHeight always report the browser pixels (ie screen resolution minus UI bars, typically 480x762 on a Galaxy S.)

You may then to throw in window.devicePixelRatio to calculate the virtual pixel width (320px).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜