我一直在网上寻找浏览器对 window.devicePixelRatio
的支持,但运气不佳。
有谁知道哪些浏览器/设备支持这个?
最佳答案
根据 this博文:(自 2012 年起)
window.devicePixelRatio
在大多数浏览器上都是值得信赖的。- 在 iOS 设备上,将
devicePixelRatio
乘以screen.width
以获得物理像素数。 - 在 Android 和 Windows Phone 设备上,将
screen.width
除以devicePixelRatio
以获得倾斜计数。
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.
桌面浏览器支持:
Chrome Edge Firefox Internet Explorer Opera Safari 49 (Yes) 49 11 41 9.1
移动浏览器:
Android Edge Firefox IE Mobile Opera Safari Mobile 4.4 (Yes) ? ? all 9.3
关于javascript - window.devicePixelRatio 浏览器支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16385573/