Screen:colorDepth 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

只读属性 Screen.colorDepth 返回屏幕的颜色深度(color depth)。根据 CSSOM(CSS 对象模型),某些实现为了兼容性原因总是返回 24。请参阅浏览器兼容性部分,以了解不这么做的浏览器。

一个数字。

示例

js
// 检测屏幕的颜色深度
if (window.screen.colorDepth < 8) {
  // 使用低色彩版本页面
} else {
  // 使用常规的彩色版页面
}

规范

Specification
CSSOM View Module
# dom-screen-colordepth

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
colorDepth

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见