Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| web:html:formulaires:pseudoclass [2023/04/05 17:23] – [Champs requis] jcheron | web:html:formulaires:pseudoclass [2023/04/07 15:46] (Version actuelle) – [Validité des données] jcheron | ||
|---|---|---|---|
| Ligne 9: | Ligne 9: | ||
| ^:focus | Cible un élément ayant le focus | | ^:focus | Cible un élément ayant le focus | | ||
| ^:active | Cible un élément activé au clavier ou à la souris | | ^:active | Cible un élément activé au clavier ou à la souris | | ||
| + | ^:required | Cible un élément requis (ayant l' | ||
| + | ^:optional| Cible un élément non requis (opposé de **: | ||
| + | ^:valid | Cible un élément valide (ou n' | ||
| + | ^:invalid | Cible un élément non requis (opposé de **:valid**) | | ||
| ==== Champs requis ==== | ==== Champs requis ==== | ||
| Ligne 45: | Ligne 48: | ||
| - | Il est possible d' | + | Il est possible d' |
| <sxh html> | <sxh html> | ||
| Ligne 61: | Ligne 64: | ||
| input: | input: | ||
| - | font-size: | + | font-size: |
| position: absolute; | position: absolute; | ||
| content: " | content: " | ||
| color: white; | color: white; | ||
| - | background-color: | + | background-color: |
| padding: 5px 10px; | padding: 5px 10px; | ||
| - | top: -26px; | + | top: -36px; |
| left: -70px; | left: -70px; | ||
| } | } | ||
| Ligne 83: | Ligne 86: | ||
| content: " | content: " | ||
| color: white; | color: white; | ||
| - | background-color: | + | background-color: |
| padding: 5px 10px; | padding: 5px 10px; | ||
| top: -36px; | top: -36px; | ||
| Ligne 98: | Ligne 101: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| + | ==== Validité des données ==== | ||
| + | |||
| + | L' | ||
| + | |||
| + | **:valid** et **: | ||
| + | * Contrôles requis (**: | ||
| + | * Contrôles avec validation native (champs input d'un certain type) invalides si la valeur saisie est non conforme. | ||
| + | * Contrôles avec limites (min et max) invalides en dehors des plages (**: | ||
| + | |||
| + | <sxh html> | ||
| + | <div> | ||
| + | <label for=" | ||
| + | <input id=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <sxh css> | ||
| + | input + span { | ||
| + | position: relative; | ||
| + | } | ||
| + | |||
| + | input + span:: | ||
| + | position: absolute; | ||
| + | right: -20px; | ||
| + | top: 5px; | ||
| + | } | ||
| + | |||
| + | input: | ||
| + | border: 2px solid red; | ||
| + | } | ||
| + | |||
| + | input: | ||
| + | content: ' | ||
| + | color: red; | ||
| + | } | ||
| + | |||
| + | input:valid + span:: | ||
| + | content: ' | ||
| + | color: green; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | # | ||
| + | width: 200px; | ||
| + | display: inline-block; | ||
| + | } | ||
| + | # | ||
| + | position: relative; | ||
| + | } | ||
| + | |||
| + | # | ||
| + | position: absolute; | ||
| + | right: -20px; | ||
| + | top: 0px; | ||
| + | margin-right: | ||
| + | } | ||
| + | |||
| + | # | ||
| + | border: 2px solid #db4764; | ||
| + | } | ||
| + | |||
| + | # | ||
| + | content: ' | ||
| + | color: #db4764; | ||
| + | } | ||
| + | |||
| + | # | ||
| + | content: ' | ||
| + | color: green; | ||
| + | } | ||
| + | # | ||
| + | font-size: 1rem; | ||
| + | position: absolute; | ||
| + | content: " | ||
| + | color: white; | ||
| + | background-color: | ||
| + | padding: 5px 10px; | ||
| + | top: -36px; | ||
| + | left: -70px; | ||
| + | border-radius: | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | <div class=" | ||
| + | <div id=" | ||
| + | <label for=" | ||
| + | <input id=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||