aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_out-of-range
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_out-of-range
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_out-of-range')
-rw-r--r--files/zh-cn/web/css/_colon_out-of-range/index.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_colon_out-of-range/index.html b/files/zh-cn/web/css/_colon_out-of-range/index.html
new file mode 100644
index 0000000000..1223744f41
--- /dev/null
+++ b/files/zh-cn/web/css/_colon_out-of-range/index.html
@@ -0,0 +1,111 @@
+---
+title: ':out-of-range'
+slug: 'Web/CSS/:out-of-range'
+translation_of: 'Web/CSS/:out-of-range'
+---
+<div>{{CSSRef}}</div>
+
+<div><strong><code>:out-of-range</code> </strong><a href="https://developer.mozilla.org/en-US/docs/Web/CSS">CSS</a> <a href="https://developer.mozilla.org/en-US/docs/CSS/Pseudo-classes">伪类</a> 表示一个 {{htmlelement("input")}} 元素,其当前值处于属性 <code><a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input#attr-min">min</a></code> 和 <code><a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input#attr-max">max</a></code> 限定的范围外。</div>
+
+<div> </div>
+
+<pre class="brush: css">/* 该伪类可选定任意的&lt;input&gt;, 但只有在该元素指定了取值范围,并且元素值处于指定范围时才有效 */
+input:out-of-range {
+ background-color: rgba(255, 0, 0, 0.25);
+}</pre>
+
+<p>该伪类用于给用户一个可视化的提示,表示输入域的当前值处于允许范围外。</p>
+
+<div class="note">注意:该伪类仅适用于那些拥有(或可以接受)取值范围设定的元素。若缺少此类设定,元素值就无所谓“in-range”和“out-range”。</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<div id="example">
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html">&lt;form action="" id="form1"&gt;
+ &lt;ul&gt;Values between 1 and 10 are valid.
+ &lt;li&gt;
+ &lt;input id="value1" name="value1" type="number" placeholder="1 to 10" min="1" max="10" value="12"&gt;
+ &lt;label for="value1"&gt;Your value is &lt;/label&gt;
+ &lt;/li&gt;
+ &lt;/ul&gt;
+&lt;/form&gt;</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css;">li {
+ list-style: none;
+ margin-bottom: 1em;
+}
+
+input {
+ border: 1px solid black;
+}
+
+input:in-range {
+ background-color: rgba(0, 255, 0, 0.25);
+}
+
+input:out-of-range {
+ background-color: rgba(255, 0, 0, 0.25);
+ border: 2px solid red;
+}
+
+input:in-range + label::after {
+ content: 'okay.';
+}
+
+input:out-of-range + label::after {
+ content: 'out of range!';
+}</pre>
+
+<h3 id="输出">输出</h3>
+</div>
+
+<div>{{EmbedLiveSample('Example', 600, 140)}}</div>
+
+<h2 id="规范"><span>规范</span></h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', 'scripting.html#selector-out-of-range', ':out-of-range')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Defines when <code>:out-of-range</code> matches elements in HTML.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS4 Selectors', '#out-of-range-pseudo', ':out-of-range')}}</td>
+ <td>{{Spec2('CSS4 Selectors')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+<div>
+
+
+<p>{{Compat("css.selectors.out-of-range")}}</p>
+</div>
+</div>
+
+<h2 id="参阅">参阅</h2>
+
+<ul>
+ <li>{{cssxref(":in-range")}}</li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Form_validation">Form data validation</a></li>
+</ul>