Files
2026-08-24 20:14:23 +02:00

155 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Scroll Snap avec Header Scrollable</title>
<style>
html, body {
margin: 0;
font-family: Arial, sans-serif;
height: 100%;
/* Scroll snap global */
scroll-snap-type: y mandatory;
overflow-y: scroll;
}
header {
height: 120px;
background-color: #34495e;
color: white;
display: flex;
align-items: center;
justify-content: center;
scroll-snap-align: start;
}
nav {
height: 80px;
background-color: #2ecc71;
display: flex;
align-items: center;
justify-content: center;
position: sticky;
top: 0;
z-index: 10;
}
section {
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
scroll-snap-align: start;
scroll-margin-top: 80px;
}
.section-1 {
background-color: #ecf0f1;
min-height: 200px;
}
.section-3 {
background-color: #95a5a6;
min-height: 200vh;
}
.section-2 {
background-color: #bdc3c7;
height: calc(100vh - 80px);
padding: 0;
display: flex;
}
/* Conteneur du tableau */
.table-wrapper {
flex: 1;
overflow-y: auto;
}
/* Tableau */
table {
width: 100%;
border-collapse: collapse;
}
/* THEAD sticky */
thead th {
position: sticky;
top: 0;
background: #ffffff;
z-index: 2;
border-bottom: 2px solid #999;
}
/* TFOOT sticky */
tfoot td {
position: sticky;
bottom: 0;
background: #ffffff;
z-index: 2;
border-top: 2px solid #999;
}
/* Style cellules */
th, td {
padding: 12px;
border: 1px solid #aaa;
text-align: left;
}
</style>
</head>
<body>
<header>
<h1>Header (120px)</h1>
</header>
<nav>
<strong>Navbar sticky (80px)</strong>
</nav>
<section class="section-1">Section 1</section>
<section class="section-2">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>Nom</th>
<th>Valeur</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr><td>Ligne 1</td><td>123</td><td>OK</td></tr>
<tr><td>Ligne 2</td><td>456</td><td>OK</td></tr>
<tr><td>Ligne 3</td><td>789</td><td>OK</td></tr>
<tr><td>Ligne 4</td><td>111</td><td>OK</td></tr>
<tr><td>Ligne 5</td><td>222</td><td>OK</td></tr>
<tr><td>Ligne 6</td><td>333</td><td>OK</td></tr>
<tr><td>Ligne 7</td><td>444</td><td>OK</td></tr>
<tr><td>Ligne 8</td><td>555</td><td>OK</td></tr>
<tr><td>Ligne 9</td><td>666</td><td>OK</td></tr>
<tr><td>Ligne 10</td><td>777</td><td>OK</td></tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Total : 10 éléments</td>
</tr>
</tfoot>
</table>
</div>
</section>
<section class="section-3">Section 3</section>
</body>
</html>