aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/css/_colon_checked
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/fr/web/css/_colon_checked
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/css/_colon_checked')
-rw-r--r--files/fr/web/css/_colon_checked/index.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/files/fr/web/css/_colon_checked/index.html b/files/fr/web/css/_colon_checked/index.html
new file mode 100644
index 0000000000..1c30f76b91
--- /dev/null
+++ b/files/fr/web/css/_colon_checked/index.html
@@ -0,0 +1,141 @@
+---
+title: ':checked'
+slug: 'Web/CSS/:checked'
+tags:
+ - CSS
+ - Pseudo-classe
+ - Reference
+translation_of: 'Web/CSS/:checked'
+---
+<div>{{CSSRef}}</div>
+
+<p>La pseudo-classe <strong><code>:checked</code></strong> représente n'importe quel <strong>bouton radio</strong> (<code><a href="/fr/docs/Web/HTML/Element/input/radio">&lt;input type="radio"&gt;</a></code>), <strong>case à cocher </strong>(<code><a href="/fr/docs/Web/HTML/Element/input/checkbox">&lt;input type="checkbox"&gt;</a></code>) ou <strong>option</strong> ({{HTMLElement("option")}} d'un élément {{HTMLElement("select")}}) qui est coché ou activé (<code>on</code>). L'utilisateur peut modifier cet état en cliquant sur l'élément ou en sélectionnant une valeur différente auquel cas la pseudo-classe <code>:checked</code> ne s'applique plus à l'élément en question.</p>
+
+<pre class="brush: css no-line-numbers">/* cible n'importe quel bouton radio sélectionné, case
+/* à cocher cochée ou option sélectionnée */
+input:checked {
+ margin-left: 25px;
+ border: 1px solid blue;
+}
+</pre>
+
+<div class="note">
+<p><strong>Note :</strong> Les navigateurs considèrent souvent les éléments <code>&lt;option&gt;</code> comme <a href="/fr/docs/Web/CSS/%C3%89l%C3%A9ment_remplac%C3%A9">des éléments remplacés</a>et la possibilité de mise en forme avec <code>:checked</code> varie d'un navigateur à l'autre.</p>
+</div>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="syntaxbox">{{csssyntax}}
+</pre>
+
+<h2 id="Exemples">Exemples</h2>
+
+<p>Ici, on utilise la pseudo-classe <code>:checked</code> pseudo-class applied to hidden checkboxes appended at the beginning of your page could be employed in order to store some dynamic booleans to be used by a CSS rule. The following example shows how to hide/show some expandable elements by simply clicking on a button (<a class="internal" href="/@api/deki/files/6246/=expandable-elements.html" title="Expandable elements through the :checked pseudoclass">download this demo</a>).</p>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css">#expand-btn {
+ margin: 0 3px;
+ display: inline-block;
+ font: 12px / 13px "Lucida Grande", sans-serif;
+ text-shadow: rgba(255, 255, 255, 0.4) 0 1px;
+ padding: 3px 6px;
+ border: 1px solid rgba(0, 0, 0, 0.6);
+ background-color: #969696;
+ cursor: default;
+ border-radius: 3px;
+ box-shadow: rgba(255, 255, 255, 0.4) 0 1px, inset 0 20px 20px -10px white;
+}
+
+#isexpanded:checked ~ #expand-btn, #isexpanded:checked ~ * #expand-btn {
+ background: #B5B5B5;
+ box-shadow: inset rgba(0, 0, 0, 0.4) 0 -5px 12px, inset rgba(0, 0, 0, 1) 0 1px 3px, rgba(255, 255, 255, 0.4) 0 1px;
+}
+
+#isexpanded, .expandable {
+ display: none;
+}
+
+#isexpanded:checked ~ * tr.expandable {
+ display: table-row;
+ background: #cccccc;
+
+}
+
+#isexpanded:checked ~ p.expandable, #isexpanded:checked ~ * p.expandable {
+ display: block;
+ background: #cccccc;
+}
+</pre>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html">&lt;input type="checkbox" id="isexpanded" /&gt;
+
+&lt;table&gt;
+ &lt;thead&gt;
+ &lt;tr&gt;&lt;th&gt;Colonne 1&lt;/th&gt;&lt;th&gt;Colonne 2&lt;/th&gt;&lt;th&gt;Colonne 3&lt;/th&gt;&lt;/tr&gt;
+ &lt;/thead&gt;
+ &lt;tbody&gt;
+ &lt;tr class="expandable"&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr class="expandable"&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;/tr&gt;
+ &lt;tr class="expandable"&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;td&gt;[cellule]&lt;/td&gt;&lt;/tr&gt;
+ &lt;/tbody&gt;
+&lt;/table&gt;
+
+&lt;p&gt;[Un texte normal]&lt;/p&gt;
+&lt;p&gt;&lt;label for="isexpanded" id="expand-btn"&gt;Afficher les éléments masqués&lt;/label&gt;&lt;/p&gt;
+&lt;p class="expandable"&gt;[Un texte caché]&lt;/p&gt;
+&lt;p&gt;[Un texte normal]&lt;/p&gt;
+</pre>
+
+<h3 id="Résultat">Résultat</h3>
+
+<p>{{EmbedLiveSample('Exemples','300','450')}}</p>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', '#selector-checked', ':checked')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Aucune modification.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', '#selector-checked', ':checked')}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>La sémantique relative au HTML est définie.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS4 Selectors', '#checked', ':checked')}}</td>
+ <td>{{Spec2('CSS4 Selectors')}}</td>
+ <td>Aucune modification.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Basic UI', '#pseudo-checked', ':checked')}}</td>
+ <td>{{Spec2('CSS3 Basic UI')}}</td>
+ <td>Lien avec la spécification de niveau 3 pour les sélecteurs.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Selectors', '#checked', ':checked')}}</td>
+ <td>{{Spec2('CSS3 Selectors')}}</td>
+ <td>Définition de la pseudo-classe mais pas de la sémantique associée.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div class="hidden">Ce tableau de compatibilité a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
+
+<p>{{Compat("css.selectors.checked")}}</p>