物理像素分辨率(安卓设备像素分辨率)与CSS 像素分辨率相互转换

比率

当前显示设备的物理像素分辨率与CSS像素分辨率之比用 window.devicePixelRatio 获取。

转换公式

物理像素分辨率 = CSS像素分辨率 * window.devicePixelRatio;
CSS像素分辨率 = 物理像素分辨率 / window.devicePixelRatio;

参考

https://developer.mozilla.org/zh-CN/docs/Web/API/Window/devicePixelRatio#浏览器兼容性

posted @ 2024-07-05 17:38  不叫一日闲过  阅读(11)  评论(0编辑  收藏  举报