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_valid/index.html | 84 +++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 files/zh-cn/web/css/_colon_valid/index.html (limited to 'files/zh-cn/web/css/_colon_valid/index.html') diff --git a/files/zh-cn/web/css/_colon_valid/index.html b/files/zh-cn/web/css/_colon_valid/index.html new file mode 100644 index 0000000000..43689bc25b --- /dev/null +++ b/files/zh-cn/web/css/_colon_valid/index.html @@ -0,0 +1,84 @@ +--- +title: ':valid' +slug: 'Web/CSS/:valid' +tags: + - CSS + - Layout + - Pesudo-class + - Reference + - Web +translation_of: 'Web/CSS/:valid' +--- +
{{ CSSRef() }}
+ +

:valid CSS 伪类表示内容验证正确的{{ HTMLElement("input") }} 或其他 {{ HTMLElement("form") }} 元素。这能简单地将校验字段展示为一种能让用户辨别出其输入数据的正确性的样式。

+ +
/* Selects any valid <input> */
+input:valid {
+  background-color: powderblue;
+}
+ +

该伪类对于高亮正确字段是很有用的。

+ +

语法

+ +
{{csssyntax}}
+ +

例子

+ +

参见 {{cssxref(":invalid")}}。

+ +

 

+ +

Accessibility concerns

+ +

绿色常用于表示有效输入。但某些色盲的人将无法确定输入的状态(颜色),除非使用不依赖于颜色来传达意义的附加指示器。 通常,指示器使用描述性文本和(或)图标。

+ + + +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', '#selector-valid', ':valid') }}{{ Spec2('HTML WHATWG') }}No change.
{{ SpecName('HTML5 W3C', '#selector-valid', ':valid') }}{{ Spec2('HTML5 W3C') }}Defines the semantic regarding HTML and constraint validation.
{{ SpecName('CSS4 Selectors', '#validity-pseudos', ':valid') }}{{ Spec2('CSS4 Selectors') }}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("css.selectors.valid")}}

+
+ +

参见

+ + -- cgit v1.2.3-54-g00ecf