How can you get the CSS pixel / device pixel ratio?

前端 未结 4 1859
臣服心动
臣服心动 2020-12-04 16:36

I want to find the ratio between CSS pixels and device pixels.

Edit: I should have realized that this is just zoom level. I\'ve added an answer to t

4条回答
  •  没有蜡笔的小新
    2020-12-04 17:12

    You can use window.devicePixelRatio in Webkit based browsers to get the device pixel ratio directly in JavaScript. I have used this on Google Chrome, Android browsers (2.2+) and Mobile Safari. I have no idea about other browsers though.

提交回复
热议问题