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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
---
title: ':indeterminate'
slug: 'Web/CSS/:indeterminate'
translation_of: 'Web/CSS/:indeterminate'
---
<div>{{CSSRef}}</div>
<p id="总结"><code>:indeterminate</code> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/Pseudo-classes">伪类</a> 表示状态不确定的表单元素:</p>
<pre><code>/* Selects any <input> whose state is indeterminate */
input:indeterminate {
background: lime;
}</code>
</pre>
<p>根据上述例子(选择器)选中的元素是:</p>
<ul>
<li><code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox"><input type="checkbox"></a></code> 元素,其 <code>indeterminate</code> 属性被 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">JavaScript</a>设置为 <code>true</code> 。</li>
<li><code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio"><input type="radio"></a></code> 元素, 表单中拥有相同 <code>name</code>值的所有单选按钮都未被选中时。</li>
<li>处于不确定状态的 {{HTMLElement("progress")}} 元素</li>
</ul>
<p> </p>
<h2 id="语法">语法</h2>
{{csssyntax}}
<h2 id="示例">示例</h2>
<h3 id="Checkbox_radio_button">Checkbox & radio button</h3>
<h4 id="CSS">CSS</h4>
<pre class="brush: css; hightlight[5]">input, span {
background: red;
}
:indeterminate, :indeterminate + label {
background: lime;
}
</pre>
<h4 id="HTML">HTML</h4>
<pre class="brush: html"><div>
<input type="checkbox" id="checkbox">
<label for="checkbox">Background should be green</label>
</div>
<div>
<input type="radio" id="radio">
<label for="radio">Background should be green</label>
</div></pre>
<h4 id="JavaScript">JavaScript</h4>
<pre class="brush: js">var inputs = document.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++) {
inputs[i].indeterminate = true;
}
</pre>
<p>{{EmbedLiveSample('Checkbox_radio_button', '100%', 50)}}</p>
<h3 id="Progress_bar">Progress bar</h3>
<h4 id="CSS_2">CSS</h4>
<pre><code>progress {
margin: 4px;
}
progress:indeterminate {
opacity: 0.5;
background-color: lightgray;
box-shadow: 0 0 2px 1px red;
}</code></pre>
<h4 id="HTML_2">HTML</h4>
<pre class="brush: html"><progress>
</pre>
<h3 id="结果">结果</h3>
<p>{{EmbedLiveSample('Progress_bar', 'auto', 30)}}</p>
<h2 id="规范">规范</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('HTML WHATWG', '#selector-indeterminate', ':indeterminate')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>No change</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', '#selector-indeterminate', ':indeterminate')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>Defines the semantic regarding HTML and constraint validation.</td>
</tr>
<tr>
<td>{{SpecName('CSS4 Selectors', '#indeterminate', ':indeterminate')}}</td>
<td>{{Spec2('CSS4 Selectors')}}</td>
<td>No change</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Basic UI', '#indeterminate', ':indeterminate')}}</td>
<td>{{Spec2('CSS3 Basic UI')}}</td>
<td>Defines the pseudo-class, but not the associated semantic.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("css.selectors.indeterminate")}}</p>
|