Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Dev tableau
:
code040.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tableau Sticky avec 3 Premières Colonnes Fixes</title> <style> /* ✅ Conteneur principal pour le scroll */ .table-wrapper { width: 100%; max-height: 400px; overflow: auto; border: 1px solid #ccc; scroll-snap-type: both mandatory; } table { width: max-content; border-collapse: collapse; } th, td { padding: 10px; text-align: center; border: 1px solid #ccc; min-width: 120px; height: 40px; scroll-snap-align: start; } /* ✅ Sticky Header */ th { background-color: #f2f2f2; position: sticky; top: 0; z-index: 10; } /* ✅ Sticky Première Colonne */ td:first-child, th:first-child { position: sticky; left: 0; background-color: white; z-index: 30; border-right: none; } /* ✅ Sticky Deuxième Colonne */ td:nth-child(2), th:nth-child(2) { position: sticky; left: 120px; /* Ajuste selon la largeur de la première colonne */ background-color: white; z-index: 25; border-right: none; } /* ✅ Sticky Troisième Colonne */ td:nth-child(3), th:nth-child(3) { position: sticky; left: 240px; /* Ajuste selon la largeur des deux premières colonnes */ background-color: white; z-index: 20; border-right: none; } /* ✅ Ajout de bordures persistantes avec ::after */ td:first-child::after, th:first-child::after, td:nth-child(2)::after, th:nth-child(2)::after, td:nth-child(3)::after, th:nth-child(3)::after { content: ""; position: absolute; right: 0; top: 0; width: 2px; height: 100%; background-color: #ccc; z-index: 35; } /* ✅ Coin supérieur gauche sticky */ th:first-child { position: sticky; top: 0; left: 0; z-index: 40; background-color: #ddd; border-bottom: 2px solid #aaa; } /* ✅ Alternance des couleurs pour lisibilité */ tbody tr:nth-child(odd) { background-color: #f9f9f9; } </style> </head> <body> <div class="table-wrapper"> <table> <thead> <tr> <th></th> <!-- ✅ Coin haut gauche --> <th>Extra 1</th> <!-- ✅ Colonne sticky 2 --> <th>Extra 2</th> <!-- ✅ Colonne sticky 3 --> <?php for ($i = 1; $i <= 50; $i++): ?> <th>Col <?php echo $i; ?></th> <?php endfor; ?> </tr> </thead> <tbody> <?php for ($i = 1; $i <= 50; $i++): ?> <tr> <td>Row <?php echo $i; ?></td> <td>Extra 1 - <?php echo $i; ?></td> <!-- ✅ Sticky Colonne 2 --> <td>Extra 2 - <?php echo $i; ?></td> <!-- ✅ Sticky Colonne 3 --> <?php for ($j = 1; $j <= 50; $j++): ?> <td>Data <?php echo $i . "-" . $j; ?></td> <?php endfor; ?> </tr> <?php endfor; ?> </tbody> </table> </div> </body> </html>