Are window.screen.width and height returned values in CSS pixels or actual screen pixels?

南笙酒味 提交于 2020-01-15 11:27:11

问题


From the API name screen and from this DOC link, I would expect them to be actual screen size pixels.

https://developer.mozilla.org/en-US/docs/Web/API/Screen/width

But from the tests I've run so far, it seems they return CSS pixels.

  • 360 for window.screen.width for my Galaxy A5 (both on Chrome and Firefox)

  • 768 for window.screen.width for my iPad (both on Chrome and Safari)

Which are CSS pixel values.

QUESTION

Is this consistent across browsers? Can I trust I'll always get CSS pixel values?


回答1:


I found the confirmation that it is in CSS pixels in the CSS spec.

https://drafts.csswg.org/cssom-view/#dom-screen-width



来源:https://stackoverflow.com/questions/59721344/are-window-screen-width-and-height-returned-values-in-css-pixels-or-actual-scree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!