aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_valid
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/_colon_valid
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/_colon_valid')
-rw-r--r--files/zh-cn/web/css/_colon_valid/index.html84
1 files changed, 84 insertions, 0 deletions
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'
+---
+<div>{{ CSSRef() }}</div>
+
+<p><code>:valid</code> CSS <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">伪类</a>表示内容<a href="/en/HTML/HTML5/Constraint_validation" title="en/HTML/HTML5/Constraint_validation">验证</a>正确的{{ HTMLElement("input") }} 或其他 {{ HTMLElement("form") }} 元素。这能简单地将校验字段展示为一种能让用户辨别出其输入数据的正确性的样式。</p>
+
+<pre class="brush: css no-line-numbers">/* Selects any valid &lt;input&gt; */
+input:valid {
+ background-color: powderblue;
+}</pre>
+
+<p>该伪类对于高亮正确字段是很有用的。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="例子">例子</h2>
+
+<p>参见 {{cssxref(":invalid")}}。</p>
+
+<p> </p>
+
+<h2 id="Accessibility_concerns">Accessibility concerns</h2>
+
+<p>绿色常用于表示有效输入。但某些色盲的人将无法确定输入的状态(颜色),除非使用不依赖于颜色来传达意义的附加指示器。 通常,指示器使用描述性文本和(或)图标。</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#Guideline_1.4_Make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background">MDN Understanding WCAG, Guideline 1.4 explanations</a></li>
+ <li><a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-without-color.html">Understanding Success Criterion 1.4.1  | W3C Understanding WCAG 2.0</a></li>
+</ul>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table" style="color: #3b3c40; font-size: 14px; font-weight: normal;">
+ <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-valid', ':valid') }}</td>
+ <td>{{ Spec2('HTML WHATWG') }}</td>
+ <td>No change.</td>
+ </tr>
+ <tr>
+ <td>{{ SpecName('HTML5 W3C', '#selector-valid', ':valid') }}</td>
+ <td>{{ Spec2('HTML5 W3C') }}</td>
+ <td>Defines the semantic regarding HTML and constraint validation.</td>
+ </tr>
+ <tr>
+ <td>{{ SpecName('CSS4 Selectors', '#validity-pseudos', ':valid') }}</td>
+ <td>{{ Spec2('CSS4 Selectors') }}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("css.selectors.valid")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{ cssxref(":invalid") }}, {{ cssxref(":required") }}, {{ cssxref(":optional") }}</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation">Form data validation</a></li>
+</ul>