javascript window.devicePixelRatio 浏览器支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16385573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
window.devicePixelRatio browser support
提问by ccdavies
I have been looking around the web to find what browser support there is for window.devicePixelRatio
, without much luck.
我一直在网上寻找什么浏览器支持 window.devicePixelRatio
,但运气不佳。
Does anyone know what browers/devices support this?
有谁知道什么浏览器/设备支持这个?
回答by Alexander
According to thisblog post : ( from 2012 )
根据这篇博文:(从 2012 年开始)
window.devicePixelRatio
is mostly trustworthy on most browsers.- On iOS devices, multiply
devicePixelRatio
byscreen.width
to get the physical pixel count. - On Android and Windows Phone devices, divide
screen.width
bydevicePixelRatio
to get the dips count.
window.devicePixelRatio
在大多数浏览器上大多是值得信赖的。- 在iOS设备上,乘
devicePixelRatio
用screen.width
得到的物理像素数。 - 在Android和Windows Phone设备,除
screen.width
通过devicePixelRatio
获得逢低计数。
2017 UPDATE:
2017年更新:
This property returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device. This value could also be interpreted as the ratio of pixel sizes: the size of one CSS pixel to the size of one physical pixel.
此属性返回当前显示设备的物理像素分辨率与 CSS 像素分辨率的比率。这个值也可以解释为像素大小的比率:一个 CSS 像素的大小与一个物理像素的大小。
Desktop browsers support:
桌面浏览器支持:
Chrome Edge Firefox Internet Explorer Opera Safari 49 (Yes) 49 11 41 9.1
Mobile Browsers:
移动浏览器:
Android Edge Firefox IE Mobile Opera Safari Mobile 4.4 (Yes) ? ? all 9.3