width

创建于 2024-12-03 / 35
字体: [默认] [大] [更大]

❮ Screen 对象

实例

获取屏幕的总宽度:

var x = "Total Width: " + screen.width; 亲自试一试 »

页面下方有更多实例。


定义和用法

width 属性返回用户屏幕的总宽度(以像素为单位)。

提示: 使用 height 属性获取用户屏幕的总高度。


浏览器支持

属性
width Yes Yes Yes Yes Yes

语法

screen.width

技术细节

返回值: 数值,表示用户屏幕的总宽度,以像素为单位

更多实例

实例

所有屏幕属性:

var txt = "";
txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight + "</p>";
txt += "<p>Color depth: " + screen.colorDepth + "</p>";
txt += "<p>Color resolution: " + screen.pixelDepth + "</p>"; 亲自试一试 »
❮ Screen 对象
0 人点赞过