Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我理解正确的话,screen.width是 JavaScript 的类似物吗
screen.width
设备宽度
在 CSS 媒体查询中。
什么是正确的 JavaScriptmax-device-width和min-device-width?
max-device-width
min-device-width
CSSmax-device-width和min-device-width运算符是谓词,因此在 JavaScript 中它们将使用关系运算符进行检查:
if (screen.width >= 100) // (min-device-width: 100) if (screen.width <= 1000) // (max-device-width: 1000)