问题
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
forwindow.screen.width
for my Galaxy A5 (both on Chrome and Firefox)768
forwindow.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