:默认 | :default
:default
:default
CSSpseudo-class表示一组相关元素中的默认表单元素。
/* Selects default element among a group */
:default {
background-color: lime;
}
允许多个选择的分组元素也可以具有多个默认值,即,它们可以具有最初选择的多个项目。在这种情况下,所有默认值都使用:default
伪类表示。例如,您可以在一组复选框之间设置默认复选框。
语法
:default
示例
:default
{
background-color: lime;
}
...在哪里...
<form method="get">
<p><input type="submit" id="submit1"></p>
<p><input type="submit" id="submit2"></p>
<p><input type="reset"></p>
</form>
这个例子使背景色成为lime
窗体中的默认提交按钮。
规范
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of ':default' in that specification. | Living Standard | No change. |
HTML5The definition of ':default' in that specification. | Recommendation | Defines the semantic regarding HTML and constraint validation. |
Selectors Level 4The definition of ':default' in that specification. | Working Draft | No change. |
CSS Basic User Interface Module Level 3The definition of ':default' in that specification. | Candidate Recommendation | Defines the pseudo-class, but not the associated semantic. |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 10.0 | 4.0 (2.0) | No support | 10.0 | 5.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 4.0 (2.0) | No support | 10.0 | 5.0 |