From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/_colon_default/index.html | 135 ++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 files/zh-cn/web/css/_colon_default/index.html (limited to 'files/zh-cn/web/css/_colon_default/index.html') diff --git a/files/zh-cn/web/css/_colon_default/index.html b/files/zh-cn/web/css/_colon_default/index.html new file mode 100644 index 0000000000..e7a3c59512 --- /dev/null +++ b/files/zh-cn/web/css/_colon_default/index.html @@ -0,0 +1,135 @@ +--- +title: ':default' +slug: 'Web/CSS/:default' +translation_of: 'Web/CSS/:default' +--- +
{{CSSRef}}
+ +

 :default CSS pseudo-class 表示一组相关元素中的默认表单元素。

+ +

该选择器可以在 {{htmlelement("button")}}, <input type="checkbox">, <input type="radio">, 以及 {{htmlelement("option")}} 上使用。

+ +
/* Selects any default <input> */
+input:default {
+  background-color: lime;
+}
+ +

允许多个选择的分组元素也可以具有多个默认值,即,它们可以具有最初选择的多个项目。在这种情况下,所有默认值都使用 :default 伪类表示。例如,您可以在一组复选框之间设置默认复选框。

+ +

语法

+ +
{{csssyntax}}
+ +

示例

+ +

HTML

+ +
<input type="radio" name="season" id="spring">
+<label for="spring">Spring</label>
+
+<input type="radio" name="season" id="summer" checked>
+<label for="summer">Summer</label>
+
+<input type="radio" name="season" id="fall">
+<label for="fall">Fall</label>
+
+<input type="radio" name="season" id="winter">
+<label for="winter">Winter</label>
+ +

CSS

+ +
input:default {
+  box-shadow: 0 0 2px 1px coral;
+}
+
+input:default + label {
+  color: coral;
+}
+ +

结果

+ +

{{EmbedLiveSample('示例')}}

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态说明
{{SpecName('HTML WHATWG', '#selector-default', ':default')}}{{Spec2('HTML WHATWG')}}无变化
{{SpecName('HTML5 W3C', '#selector-default', ':default')}}{{Spec2('HTML5 W3C')}}定义了HTML语义和规范验证
{{SpecName('CSS4 Selectors', '#default-pseudo', ':default')}}{{Spec2('CSS4 Selectors')}}无变化
{{SpecName('CSS3 Basic UI', '#pseudo-default', ':default')}}{{Spec2('CSS3 Basic UI')}}定义了伪类,但不关联伪类
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support10.0{{CompatGeckoDesktop("2.0")}}{{CompatNo}}10.05.0
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatGeckoMobile("2.0")}}{{CompatNo}}10.05.0
+
-- cgit v1.2.3-54-g00ecf