如何计算设备像素比例 [英] How to calculate device pixel ratio

查看:546
本文介绍了如何计算设备像素比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何计算-webkit-device-pixel-ratio。我已经读过这个:
http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html.Yet 我无法清楚地理解它。
我也想知道是否有哪个设备使用哪个像素比例的列表。android网站上说:

lockquote

Android Browser和WebView支持CSS媒体功能,允许您为特定的屏幕密度创建样式-webkit-device-pixel-ratio CSS媒体功能。您应用于此功能的值应该是0.75,1或1.5,以表明这些样式分别适用于低密度,中密度或高密度屏幕的设备。


但我发现我们需要使用-webkit-device-pixel-ratio = 2来使一个Web应用程序在768 x 1280分辨率屏幕上兼容。 / b>

解决方案

据这篇文章

http://www.html5rocks.com/en/mobile/high-dpi/



幻数似乎为150. p

将物理ppi除以150的理想ppi,可得出设备像素比率。

例如一个445ppi的设备将有一个dpr为3 - >> 445/150



简单的计算似乎对这个列表上的很多项目都没有影响,



http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density


I would like to know how the -webkit-device-pixel-ratio is calculated.I had already read this: http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html.Yet I am unable to understand it clearly. I would also like to know if there is a list of which devices use which pixel ratio.The android website says

The Android Browser and WebView support a CSS media feature that allows you to create styles for specific screen densities—the -webkit-device-pixel-ratio CSS media feature. The value you apply to this feature should be either "0.75", "1", or "1.5", to indicate that the styles are for devices with low density, medium density, or high density screens, respectively.

but I found that we need to use -webkit-device-pixel-ratio=2 to make a web application compatible on 768 x 1280 resolution screen.

解决方案

According to this article

http://www.html5rocks.com/en/mobile/high-dpi/

The magic number seems to be 150.

Dividing the physical ppi by the ideal ppi of 150, gives the device pixel ratio.

E.g. a device with 445ppi would have a dpr of 3 ->> 445 / 150

The simple calculation seems to hold up okay for many items on this list,

http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density

这篇关于如何计算设备像素比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆