:indeterminate

这篇翻译不完整。请帮忙从英语翻译这篇文章

总结

:indeterminate CSS 伪类描述了:

  • indeterminate 属性被 JavaScript 置为 true 的 <input type="checkbox"> 元素 
  • 所有 radio 按钮都未被选中的 <input type="radio"> 元素
  • 处于 indeterminate 状态的 <progress> 元素

语法

:indeterminate { style properties }

示例

Checkbox & radio button

CSS

input, span {
  background: red;
}

:indeterminate, :indeterminate + label {
  background: lime;
}

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>

JavaScript

var inputs = document.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++) {
  inputs[i].indeterminate = true;
}

Progress 元素

CSS

:indeterminate {
  opacity: 0.5;
}

HTML

<progress>

结果

规范

Specification Status Comment
WHATWG HTML Living Standard
:indeterminate
Living Standard No change
HTML5
:indeterminate
Recommendation Defines the semantic regarding HTML and constraint validation.
Selectors Level 4
:indeterminate
Working Draft No change
CSS Basic User Interface Module Level 3
:indeterminate
Candidate Recommendation Defines the pseudo-class, but not the associated semantic.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Edge Opera Safari
type="checkbox" (Yes) 3.6 (1.9.2) 9.0 (Yes) 10.60 (2.6) 3.0
<progress> 6.0 6.0 (6.0) 10 (Yes) ? 5.2
type="radio" 39.0 51 (51)[1] 未实现 未实现[2] ? 未实现[3]
Feature Android Firefox Mobile (Gecko) IE Mobile Edge Opera Mobile Safari Mobile
type="checkbox" ? 1.0 (1.9.2) ? (Yes) ? ?
<progress> ? 6.0 (6.0) ? (Yes) ? ?
type="radio" 39.0 51.0 (51.0)[1] 未实现 未实现[2] ? 未实现[3]

[1] Implemented in bug 885359.

[2] See Edge bug 7124038

[3] See WebKit bug 156270

文档标签和贡献者

 此页面的贡献者: holynewbie
 最后编辑者: holynewbie,