From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- files/ca/web/css/_colon_in-range/index.html | 110 ++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 files/ca/web/css/_colon_in-range/index.html (limited to 'files/ca/web/css/_colon_in-range') diff --git a/files/ca/web/css/_colon_in-range/index.html b/files/ca/web/css/_colon_in-range/index.html new file mode 100644 index 0000000000..a8fd5171be --- /dev/null +++ b/files/ca/web/css/_colon_in-range/index.html @@ -0,0 +1,110 @@ +--- +title: ':in-range' +slug: 'Web/CSS/:in-range' +tags: + - CSS + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:in-range' +--- +
{{CSSRef}}
+ +

La pseudo-class CSS :in-range representa un element {{htmlelement("input")}} en què el seu valor actual està dins dels límits de rang especificats pels atributs {{htmlattrxref("min", "input")}} i {{htmlattrxref("max","input")}}.

+ +
/* Selecciona qualsevol <input>, però només quan té un rang especificat, i el seu valor està dins d'aquest rang */
+input:in-range {
+  background-color: rgba(0, 255, 0, 0.25);
+}
+ +

Aquesta pseudo-class és útil per donar a l'usuari una indicació visual que el valor actual, d'un camp, està dins dels límits permesos.

+ +
Nota Aquesta pseudo-class només s'aplica als elements que tenen (i poden tenir) una limitació de rang. Mancant tal limitació, l'element no pot estar "en rang" ni "fora de rang".
+ +

Sintaxi

+ +
{{csssyntax}}
+ +

Exemple

+ +
+

HTML

+ +
<form action="" id="form1">
+  <ul>Values between 1 and 10 are valid.
+    <li>
+      <input id="value1" name="value1" type="number" placeholder="1 to 10" min="1" max="10" value="12">
+      <label for="value1">Your value is </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: 'okay.';
+}
+
+input:out-of-range + label::after {
+  content: 'out of range!';
+}
+ +

Resultat

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

Especificacions

+ + + + + + + + + + + + + + + + + + + + + +
EspecificacióEstatComentari
{{SpecName('HTML WHATWG', 'scripting.html#selector-in-range', ':in-range')}}{{Spec2('HTML WHATWG')}}Defineix quan :in-range coincideix en elements HTML.
{{SpecName('CSS4 Selectors', '#in-range-pseudo', ':in-range')}}{{Spec2('CSS4 Selectors')}}Definició inicial.
+ + + +
{{Compat("css.selectors.in-range")}}
+ +

 

+ +

Vegeu també

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