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/ja/web/css/_colon_out-of-range/index.html | 117 ++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 files/ja/web/css/_colon_out-of-range/index.html (limited to 'files/ja/web/css/_colon_out-of-range/index.html') diff --git a/files/ja/web/css/_colon_out-of-range/index.html b/files/ja/web/css/_colon_out-of-range/index.html new file mode 100644 index 0000000000..7afe975a9e --- /dev/null +++ b/files/ja/web/css/_colon_out-of-range/index.html @@ -0,0 +1,117 @@ +--- +title: ':out-of-range' +slug: 'Web/CSS/:out-of-range' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Selectors + - UI Selector +translation_of: 'Web/CSS/:out-of-range' +--- +
{{CSSRef}}
+ +

:out-of-rangeCSS擬似クラスで、 {{htmlelement("input")}} 要素のうち、現在の値が {{htmlattrxref("min", "input")}} および {{htmlattrxref("max","input")}} 属性で指定された範囲を外れているものを表します。

+ +
/* 入力範囲が設定されていて、値がその範囲外である
+   <input> 要素をすべて選択 */
+input:out-of-range {
+  background-color: rgba(255, 0, 0, 0.25);
+}
+ +

この擬似クラスは。入力欄の現在の値が許可された範囲外にあることをユーザーに視覚的に示すのに便利です。

+ +
注: この擬似クラスは範囲制限を持つ (または設定できる) 要素にのみ適用されます。そのような制限がない場合は、要素は "in-range" にも "out-of-range" にもなりません。
+ +

構文

+ +
{{csssyntax}}
+ +

+ +
+

HTML

+ +
<form action="" id="form1">
+ <p>1から10の間の値が有効です。</p>
+  <ul>
+    <li>
+      <input id="value1" name="value1" type="number" placeholder="1 to 10" min="1" max="10" value="12">
+      <label for="value1">あなたの値は</label>
+    </li>
+  </ul>
+</form>
+ +

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: '範囲内です。';
+}
+
+input:out-of-range + label::after {
+  content: '範囲外です!';
+}
+ +

結果

+
+ +
{{EmbedLiveSample('Examples', 600, 140)}}
+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', 'scripting.html#selector-out-of-range', ':out-of-range')}}{{Spec2('HTML WHATWG')}}いつ HTML が :out-of-range に該当するかを定義。
{{SpecName('CSS4 Selectors', '#out-of-range-pseudo', ':out-of-range')}}{{Spec2('CSS4 Selectors')}}初回定義
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("css.selectors.out-of-range")}}

+
+ +

関連情報

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