Returns the bit depth of the screen. Per the CSSOM, some implementations return
24
for compatibility reasons. See the
browser compatibility
section for those that don't.
let depth = window.screen.pixelDepth
// if there is not adequate bit depth
// choose a simpler color
if ( window.screen.pixelDepth > 8 ) {
document.style.color = "#FAEBD7";
} else {
document.style.color = "#FFFFFF";
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSSOM (CSS 对象模型) 视图模块
The definition of 'Screen.pixelDepth' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pixelDepth
|
Chrome
40
|
Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari 6 |
WebView Android
Yes
|
Chrome Android
Yes
|
Firefox Android Yes | Opera Android Yes | Safari iOS Yes |
Samsung Internet Android
Yes
|
完整支持
兼容性未知
见实现注意事项。
Screen
AnimationEvent
CSS
CSSConditionRule
CSSGroupingRule
CSSKeyframeRule
CSSKeyframesRule
CSSMediaRule
CSSNamespaceRule
CSSPageRule
CSSRule
CSSRuleList
CSSStyleDeclaration
CSSStyleRule
CSSStyleSheet
CSSSupportsRule
CaretPosition
LinkStyle
MediaQueryList
MediaQueryListListener
StyleSheet
StyleSheetList
TransitionEvent