File "code038.php"

Full Path: /home/analogde/www/Design/Dev tableau/code038.php
File size: 2.64 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 + Scroll Snap Fix</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;
            scroll-padding: 0px;
        }

        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 First Column avec effet de bordure visible sous Chrome */
        td:first-child, th:first-child {
            position: sticky;
            left: 0;
            background-color: white;
            z-index: 20;
            border-right: none; /* Désactiver la bordure qui disparaît */
            box-shadow: 3px 0 5px rgba(0, 0, 0, 0.2); /* ✅ Bordure simulée */
        }

        /* ✅ Coin supérieur gauche sticky */
        th:first-child {
            position: sticky;
            top: 0;
            left: 0;
            z-index: 30;
            background-color: #ddd;
            border-bottom: 2px solid #aaa;
            box-shadow: 3px 0 5px rgba(0, 0, 0, 0.2); /* ✅ Bordure persistante */
        }

        /* ✅ 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 -->
                <?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>
                    <?php for ($j = 1; $j <= 50; $j++): ?>
                        <td>Data <?php echo $i . "-" . $j; ?></td>
                    <?php endfor; ?>
                </tr>
            <?php endfor; ?>
        </tbody>
    </table>
</div>

</body>
</html>