javascript - window.devicePixelRatio 浏览器支持

标签 javascript cross-browser

我一直在网上寻找浏览器对 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

Draft Spec

关于javascript - window.devicePixelRatio 浏览器支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16385573/

相关文章:

html - CSS 翻转动画在 Safari 中不起作用

html - css text-decoration 下划线在应用于输入按钮的文本时不起作用

javascript - 如何将具有 z 索引的 <img> 居中?

javascript - Bootstrap 子菜单单击子菜单 2 时如何关闭子菜单 1

javascript - lodash/js : Filtering values within an object based on regular expressions and getting the highest by comparison

jquery - 相同的源代码 - 不同的浏览器 - jQuery 插件适用于 Firefox 和 Chrome,不适用于 IE 9

javascript - 一个简单的 GetElementById 问题真的很简单

javascript - 使用 JavaScript 编辑 CSS 渐变

css - Opera、边界半径和溢出 :hidden

javascript - 如何检测浏览器强制刷新事件 - 跨浏览器