Screen: width 属性
Screen.width 只读属性返回屏幕的宽度(以 CSS 像素为单位)。
值
一个数字。
示例
js
// Crude way to check that the screen is at least 1024x768
if (window.screen.width >= 1024 && window.screen.height >= 768) {
// Resolution is 1024x768 or above
}
注意
请注意,此属性提供的宽度并不一定全部可供窗口本身使用。当其他控件占用了window对象无法使用的空间时,window.screen.width和window.screen.availWidth之间会存在差异。另请参阅screen.height。
规范
| 规范 |
|---|
| CSSOM 视图模块 # dom-screen-width |
浏览器兼容性
加载中…