File "table_boostrap_0010.php"
Full Path: /home/analogde/www/Dev tableau/table_boostrap_0010.php
File size: 3.8 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 avec Défilement</title>
<!-- Lien vers Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEJ6hu7N9R3K5wCoPY5i2hPnZjVqX7f2FMY6rnxjtb+HAjsaayjGVoF2A+Ug5" crossorigin="anonymous">
<style>
/* Style personnalisé */
.table-container {
overflow-x: auto; /* Barre de défilement horizontale */
width: 100%;
max-width: 100%; /* Pour s'assurer que la table ne dépasse pas */
}
table {
width: 100%;
table-layout: fixed; /* Appliquer un layout fixe */
border-collapse: collapse; /* Supprimer les espaces entre les cellules */
}
th, td {
text-align: center;
padding: 15px 25px; /* Augmenter la taille des cellules pour la lisibilité */
border: 1px solid #dee2e6; /* Bordures visibles */
white-space: nowrap; /* Pour éviter que le texte dépasse */
}
/* Fixer la largeur de la 1ère colonne */
th:nth-child(1), td:nth-child(1) {
position: sticky;
left: 0;
background-color: #f8f9fa;
z-index: 2;
width: 120px; /* Largeur fixe pour la 1ère colonne */
}
/* Fixer la largeur de la 2ème colonne et supprimer l'espace */
th:nth-child(2), td:nth-child(2) {
position: sticky;
left: 120px; /* Positionner après la 1ère colonne */
background-color: #f8f9fa;
z-index: 1;
width: 120px; /* Largeur fixe pour la 2ème colonne */
}
/* Ajouter un peu d'espace pour mieux visualiser */
th {
background-color: #007bff;
color: white;
}
td {
background-color: #f1f1f1;
}
/* Appliquer une largeur minimale aux colonnes supplémentaires */
th:nth-child(n+3), td:nth-child(n+3) {
width: 150px; /* Largeur fixe pour les colonnes à partir de la 3ème */
}
</style>
</head>
<body>
<div class="container mt-5">
<div class="table-container">
<table class="table table-bordered">
<thead>
<tr>
<th>Jour</th>
<th>Mois</th>
<th>Semaine</th>
<?php
// Générer les colonnes supplémentaires jusqu'à 200
for ($i = 4; $i <= 200; $i++) {
echo "<th>Colonne $i</th>";
}
?>
</tr>
</thead>
<tbody>
<tr>
<td>Total</td>
<td></td>
<td></td>
<?php
// Générer les valeurs pour chaque colonne (exemple)
for ($i = 4; $i <= 200; $i++) {
echo "<td>Valeur $i</td>";
}
?>
</tr>
<tr>
<td>Jour 1</td>
<td>Janvier</td>
<td>1</td>
<?php
// Remplir les valeurs pour chaque colonne
for ($i = 4; $i <= 200; $i++) {
echo "<td>Valeur $i</td>";
}
?>
</tr>
<tr>
<td>Jour 2</td>
<td>Février</td>
<td>2</td>
<?php
// Remplir les valeurs pour chaque colonne
for ($i = 4; $i <= 200; $i++) {
echo "<td>Valeur $i</td>";
}
?>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Lien vers Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-KyZXEJ6hu7N9R3K5wCoPY5i2hPnZjVqX7f2FMY6rnxjtb+HAjsaayjGVoF2A+Ug5" crossorigin="anonymous"></script>
</body>
</html>