File "code062.php"

Full Path: /home/analogde/www/Design/Dev tableau/code062.php
File size: 3.69 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 Bordures Fixes</title>
    <style>
        /* Conteneur pour le défilement */
        .table-wrapper {
            width: 100%;
            max-height: 400px;
            overflow: auto;
            border: 1px solid #ccc;
            position: relative;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 10px;
            text-align: center;
            vertical-align: middle;
            border: 1px solid #ccc;
            height: 40px;
            box-sizing: border-box;
        }

        /* En-têtes sticky */
        th {
            background-color: #f2f2f2;
            position: sticky;
            top: 0;
            z-index: 10;
            border-bottom: 2px solid #aaa;
        }

        /* Première colonne sticky */
        th:first-child, td:first-child {
            position: sticky;
            left: 0;
            background-color: white;
            z-index: 20;
            border-right: 2px solid #ccc;
            box-sizing: border-box;
            border-left: 2px solid #ccc;
            width: 150px; /* Largeur de la première colonne */
        }

        /* Deuxième colonne sticky */
        th:nth-child(2), td:nth-child(2) {
            position: sticky;
            left: 150px; /* Ajustement en fonction de la largeur de la première colonne */
            background-color: white;
            z-index: 19;
            border-right: 2px solid #ccc;
            box-sizing: border-box;
            border-left: 2px solid #ccc;
            width: 150px; /* Largeur de la deuxième colonne */
        }

        /* Troisième colonne sticky */
        th:nth-child(3), td:nth-child(3) {
            position: sticky;
            left: 300px; /* Ajustement en fonction de la largeur de la deuxième colonne */
            background-color: white;
            z-index: 18;
            border-right: 2px solid #ccc;
            box-sizing: border-box;
            border-left: 2px solid #ccc;
            width: 150px; /* Largeur de la troisième colonne */
        }

        /* Alternance des couleurs pour lisibilité */
        tbody tr:nth-child(odd) {
            background-color: #f9f9f9;
        }

        /* 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;
        }
    </style>
</head>
<body>

<div class="table-wrapper">
    <table>
        <thead>
            <tr>
                <th></th> <!-- Coin supérieur gauche -->
                <th>plouf</th> <!-- Deuxième colonne sticky -->
                <th>cretin</th> <!-- Troisième colonne sticky -->
                <?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>Data <?php echo $i; ?>-1</td>
                    <td>Data <?php echo $i; ?>-2</td>
                    <?php for ($j = 1; $j <= 50; $j++): ?>
                        <td>Data <?php echo $i . "-" . ($j + 2); ?></td>
                    <?php endfor; ?>
                </tr>
            <?php endfor; ?>
        </tbody>
    </table>
</div>

</body>
</html>