File "code036.php"
Full Path: /home/analogde/www/Dev tableau/code036.php
File size: 3.5 KB
MIME-type: text/html
Charset: utf-8
<!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 Scroll Snap (Fix Firefox)</title>
<style>
.table-wrapper {
width: 100%;
max-height: 400px;
overflow-y: auto;
border: 1px solid #ccc;
scroll-snap-type: y mandatory;
}
.table-scroll {
overflow-x: auto;
scroll-snap-type: x mandatory;
display: flex;
}
/* ✅ Correction avec des divs pour le snap */
.table-container {
display: flex;
flex-direction: column;
min-width: 2000px; /* Force le scroll horizontal */
}
.row-wrapper {
display: flex;
flex-wrap: nowrap;
scroll-snap-align: start;
}
.cell-wrapper {
display: flex;
align-items: center;
justify-content: center;
min-width: 120px;
height: 40px;
border: 1px solid #ccc;
text-align: center;
white-space: nowrap;
scroll-snap-align: start;
}
/* ✅ Sticky Header */
.header {
position: sticky;
top: 0;
background-color: #f2f2f2;
z-index: 1000;
}
/* ✅ Sticky First Column */
.first-column {
position: sticky;
left: 0;
background-color: #fff;
z-index: 999;
}
/* ✅ Bordure droite persistante */
.first-column::after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 2px;
height: 100%;
background-color: #ccc;
}
/* ✅ Sticky haut-gauche */
.corner {
position: sticky;
top: 0;
left: 0;
z-index: 1001;
background-color: #eee;
}
/* ✅ Bordure inférieure persistante */
.corner::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background-color: #ccc;
}
/* ✅ Alternance des couleurs */
.row-wrapper:nth-child(odd) .cell-wrapper {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<div class="table-wrapper">
<div class="table-scroll">
<div class="table-container">
<!-- En-tête -->
<div class="row-wrapper">
<div class="cell-wrapper corner"></div> <!-- ✅ Coin haut gauche -->
<?php for ($i = 1; $i <= 50; $i++): ?>
<div class="cell-wrapper header">Col <?php echo $i; ?></div>
<?php endfor; ?>
</div>
<!-- Corps du tableau -->
<?php for ($i = 1; $i <= 50; $i++): ?>
<div class="row-wrapper">
<div class="cell-wrapper first-column">Row <?php echo $i; ?></div>
<?php for ($j = 1; $j <= 50; $j++): ?>
<div class="cell-wrapper">Data <?php echo $i . "-" . $j; ?></div>
<?php endfor; ?>
</div>
<?php endfor; ?>
</div>
</div>
</div>
</body>
</html>