<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tableau avec Sticky Header et Sticky Colonne</title>
<style>
table {
width: 100%;
max-width: 1200px;
max-height: 400px;
border-collapse: collapse;
overflow: auto;
display: block;
}
th, td {
padding: 10px;
border: 1px solid #ccc;
text-align: center;
}
/* Sticky Header */
th {
background-color: #f2f2f2;
position: sticky;
top: 0;
z-index: 2;
}
/* Sticky First Column */
td:first-child, th:first-child {
background-color: #f2f2f2;
position: sticky;
left: 0;
z-index: 1;
}
/* Défilement du tableau */
.table-wrapper {
overflow: auto;
max-height: 400px;
}
</style>
</head>
<body>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th></th>
<!-- Création des en-têtes de colonnes (50 colonnes) -->
<?php for ($i = 1; $i <= 50; $i++): ?>
<th>Col <?php echo $i; ?></th>
<?php endfor; ?>
</tr>
</thead>
<tbody>
<!-- Création des lignes -->
<?php for ($i = 1; $i <= 50; $i++): ?>
<tr>
<td>Row <?php echo $i; ?></td>
<!-- Création des cellules de données -->
<?php for ($j = 1; $j <= 50; $j++): ?>
<td>Data <?php echo $i . "-" . $j; ?></td>
<?php endfor; ?>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
</body>
</html>