aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/screen/pixeldepth/index.html
blob: c96b7e4253929a86b30adbd129478a2dbff5c88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: Screen.pixelDepth
slug: Web/API/Screen/pixelDepth
tags:
  - API
translation_of: Web/API/Screen/pixelDepth
---
<div>{{APIRef("CSSOM View")}}</div>

<h2 id="Summary" name="Summary">概述</h2>

<p>返回屏幕的位深度/色彩深度(bit depth)。根据CSSOM( CSS对象模型 )视图,为兼容起见,该值总为24。</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="syntaxbox">depth = window.screen.pixelDepth
</pre>

<h2 id="Example" name="Example">示例</h2>

<pre class="brush:js">// 如果没有足够的位深度/色彩深度(bit depth),就选择一个更纯的颜色
if ( window.screen.pixelDepth &gt; 8 ) {
  document.style.color = "#FAEBD7";
} else {
  document.style.color = "#FFFFFF";
}
</pre>

<h2 id="Specification" name="Specification">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSSOM View', '#dom-screen-pixeldepth', 'Screen.pixelDepth') }}</td>
   <td>{{ Spec2('CSSOM View') }}</td>
  </tr>
 </tbody>
</table>

<h2 id="See_also" name="See_also">相关链接</h2>

<ul>
 <li>{{domxref("Screen.colorDepth")}}</li>
</ul>