Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Titre du document</title> <style> table,tr,th,td{ border:1px solid #ccc; text-align:center; border-collapse:collapse; padding:8px; } #toggle { display: none; } .expandable { visibility: collapse; background: #1c87c9; } #btn { display: inline-block; margin-top: 15px; padding: 10px 20px; background-color: #8ebf42; color: #fff; cursor:pointer; border-radius: 3px; } #toggle:checked ~ * .expandable { visibility: visible; } #toggle:checked ~ #btn { background-color: #ccc; } </style> </head> <body> <h2>exemple de sélecteur ::checked </h2> <input type="checkbox" id="toggle" /> <table> <thead> <tr> <th>Colonne 1</th> <th>Colonne 2</th> <th>Colonne 3</th> </tr> </thead> <tbody> <tr class="expandable"> <td>[plus de texte]</td> <td>[plus de texte]</td> <td>[plus de texte]</td> </tr> <tr> <td>[texte]</td> <td>[texte]</td> <td>[texte]</td> </tr> <tr class="expandable"> <td>[plus de texte]</td> <td>[plus de texte]</td> <td>[plus de texte]</td> </tr> <tr> <td>[texet]</td> <td>[texte]</td> <td>[textet]</td> </tr> <tr class="expandable"> <td>[plus de texte]</td> <td>[plus de texte]</td> <td>[plus de texte]</td> </tr> </tbody> </table> <label for="toggle" id="btn">Cliquez ici!</label> </body> </html>