IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Mise en page CSS Discussion :

Position TABLE avec scrolling


Sujet :

Défilement en CSS

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2019
    Messages
    83
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2019
    Messages : 83
    Par défaut Position TABLE avec scrolling
    Bonjour,

    Je rencontre un problème avec la fonction overflow-y:auto, quand je l'ajoute à mon tbody,ma page présente une largeur de plus qui se rajoute à droite de la page et qui active un scrolling de la page alors que je voudrais que mon tableau reste centré au milieu de la page tout simplement.. Pourtant le scrolling marche parfaitement en lui-même..

    Voici une petite illustration pour comprendre :

    Sans la barre de scrolling :

    Nom : Capture d’écran 2019-09-12 à 11.40.55.png
Affichages : 536
Taille : 264,9 Ko

    Avec la barre de scrolling :

    Nom : Capture d’écran 2019-09-12 à 11.41.25.png
Affichages : 466
Taille : 270,6 Ko

    Voici mon code HTML :

    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    <!DOCTYPE html>
    <html>
    <head>
    	<title>PA - Liste des utilisateurs</title>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
      <link rel="stylesheet" href="css/list.css">
      <meta name="viewport" content="width=device-width, initial-scale=1">
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<link rel="icon" href="https://www.proactiveacademy.fr/wp-content/uploads/2018/01/cropped-favicon-32x32.png" sizes="32x32" />
      <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">
    </head>
    <body class="d-flex flex-column justify-content-center">
      <div id="page-content">
        <nav class="navbar navbar-expand-md bg-dark navbar-dark">
          <a class="navbar-brand"><img src="http://www.proactiveacademy.fr/wp-content/uploads/2018/01/p-proactive-1.png" class="img-fluid" alt="Responsive image"></a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="collapsibleNavbar">
            <ul class="navbar-nav mx-auto">
              <li class="nav-item">
                <?php
    $sql = $db->prepare('SELECT * FROM BDD ORDER BY Id DESC LIMIT 50');
    $sql -> execute(array()); //Exécution de la requete
     
    while ($ligneencours = $sql -> fetch(PDO::FETCH_ASSOC)) { //Tant qu'il y a un enregistrement dans la table on l'associe à une ligne du tableau
        // Les lignes de variables du tableau
        $export[] = array($ligneencours["Id"], $ligneencours["id_cv"], $ligneencours["Nom"], $ligneencours["Prenom"], $ligneencours["Telephone"], $ligneencours["Email"], $ligneencours["QPV"], $ligneencours["Sexe"], $ligneencours["Ville"], $ligneencours["CodePostale"], $ligneencours["Adresse"], $ligneencours["Diplomevise"], $ligneencours["Contratvise"], $ligneencours["Dernierdiplome"], $ligneencours["Niveaudeformation"], $ligneencours["Secteuractivité"], $ligneencours["Formationvise"], $ligneencours["Specialitee"], $ligneencours["Niveau"], $ligneencours["Metier"], $ligneencours["Rythme"], $ligneencours["Structure"], $ligneencours["Sourcing"]);
    }
     
        // Nom du fichier et delimiteur entre chaque entrées
        $chemin = 'inscrits.csv';
        $delimiteur = ';'; // Pour une tabulation, $delimiteur = "t";
     
        // Création du fichier csv
        // fopen : Ouvre un fichier
        /*
            w+ : Ouvre en lecture et écriture ;
            Place le pointeur de fichier au début du fichier et réduit la taille du fichier à 0.
            Si le fichier n'existe pas, on tente de le créer.
        */
        $fichier_csv = fopen($chemin, 'w+');
     
        /*
            Si votre fichier a vocation a être importé dans Excel,
            vous devez impérativement utiliser la ligne ci-dessous pour corriger
            les problèmes d'affichage des caractères internationaux (les accents par exemple)
        */
        fprintf($fichier_csv, chr(0xEF).chr(0xBB).chr(0xBF));
     
        // On affiche une fois l'entête sans boucle
        $entetes = array('Id', 'Nom_CV', 'Nom', 'Prénom', 'Telephone', 'Email', 'QPV', 'Sexe', 'Ville', 'Code Postal', 'Adresse', 'Diplome visé', 'Contrat visé', 'Dernier Diplôme', 'Niveau de formation', 'Secteur Activité', 'Formation visé', 'Specialitée', 'Niveau', 'Métier', 'Rythme', 'Structure', 'Sourcing');
        fputcsv($fichier_csv, $entetes, $delimiteur);
     
        // Boucle foreach sur chaque ligne du tableau
        // Boucle pour se déplacer dans les tableaux
        foreach ($export as $ligneaexporter) {
            // chaque ligne en cours de lecture est insérée dans le fichier
            // les valeurs présentes dans chaque ligne seront séparées par $delimiteur
            fputcsv($fichier_csv, $ligneaexporter, $delimiteur);
        }
     
        // fermeture du fichier csv
        fclose($fichier_csv);
     ?>
                <a class="nav-link" href="inscrits.csv"><i class="fas fa-download"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="add.php"><i class="fas fa-user-plus"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="add_csv.php"><i class="fas fa-users"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt"></i></a>
              </li>
            </ul>
          </div>
                  <span class="navbar-text right-align" style="text-align: right;">Bienvenue, <?php echo $_SESSION['Prenom']?></span>
        </nav>
    	</header>
      <?php
      if (!empty($_POST["delete"])) {
          echo "<div class=\"alert alert-success \"><center><strong>Parfait !</strong><class=\"alert-link\"> Les ou les utilisateurs ont bien été supprimés.</center></div>";
      }
        ?>
    	<main class="flex-fill justify-content-center align-items-center">
            <div class="main"><br/><br/>
                <div class="container-fluid"><br/><br/>
                  <div class="options">
                    <div class="form-group has-search">
                      <span class="fa fa-search form-control-feedback"></span>
                    <form method="post" action="list.php">
                    <div class="searchbar"><input type="text" class="form-control" value="Rechercher un utilisateur" name="Search" onclick="this.value='';"></div></form>
                    <form method="post" action="list.php">
                      <input type="submit" class="btn btn-danger" style="width: 130px;" value="Supprimer" name="supprimer">
                    </div>
                  </div>
                <div class="row h-1">
                    <div class="col-sm-13 mx-auto">
                  <table class="table table-striped table-responsive table-hover" id="myTable">
                  <thead class="thead-dark" style="width:10%;">
                    <tr>
                        <th style="width:2%;" id="Choix"></th>
                        <th id="Nom" class="selection" data-tri="1" data-type="num">NOM</th>
                        <th id="Prenom">PRÉNOM</th>
                        <th id="Sexe">SEXE</th>
                        <th id="Telephone" >TELEPHONE</th>
                        <th id="E-mail">EMAIL</th>
                        <th id="Code-Postale" scope="col">CODE POSTALE</th>
                        <th id="Adresse" scope="col">ADRESSE</th>
                        <th id="Ville" scope="col">VILLE</th>
                        <th id="QPV" scope="col">QPV</th>
                        <th id="DernierDiplome" scope="col">DERNIER DIPLÔME</th>
                        <th id="Formationvise" scope="col">FORMATION VISEE</th>
                        <th id="Specialitee" scope="col">SPECIALITEE</th>
                        <th id="Niveau" scope="col">NIVEAU DE FORMATION VISE</th>
                        <th id="Metier" scope="col">METIER</th>
                        <th id="Contratvise" scope="col">CONTRAT VISE</th>
                        <th id="Rythme" scope="col">RYTHME D'ALTERNANCE</th>
                        <th id="Structure" scope="col">STRUCTURE</th>
                        <th id="Entreprise" scope="col">ENTREPRISE</th>
                        <th id="Commentaires" scope="col">COMMENTAIRES</th>
                        <th id="Upload" style="width:6%" scope="col">UPLOAD</th>
                        <th style="width:7%;" id="Edit" scope="col">MODIFICATION</th>
                        <th id="CV" style="width:5%;" scope="col"></th>
                    </tr>
                  </thead>
                  <tbody>
    <?php           while ($donne = $requete_page->fetch()) { ?>
    				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="<?php echo $donne['Id']; ?>" /></td>
    					<td class="w-25"><?php echo $donne['Nom']; ?></td>
    					<td class="w-25"><?php echo $donne['Prenom']; ?></td>
    					<td><?php echo $donne['Sexe']; ?></td>
    					<td><?php echo $donne['Telephone']; ?></td>
    					<td><?php echo $donne['Email']; ?></td>
    					<td><?php echo $donne['CodePostale']; ?></td>
              <td><?php echo $donne['Adresse']; ?></td>
              <td><?php echo $donne['Ville']; ?></td>
    					<td><?php echo $donne['QPV']; ?></td>
              <td><?php echo $donne['Dernierdiplome']; ?></td>
              <td><?php echo $donne['Formationvise']; ?></td>
              <td><?php echo $donne['Specialitee']; ?></td>
              <td><?php echo $donne['Niveau']; ?></td>
              <td><?php echo $donne['Metier']; ?></td>
              <td><?php echo $donne['Contratvise']; ?></td>
              <td><?php echo $donne['Rythme']; ?></td>
              <td><?php echo $donne['Structure']; ?></td>
              <td><?php echo $donne['Entreprise']; ?></td>
              <td><?php echo $donne['Commentaires']; ?></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=<?php echo $donne['Id']; ?>">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=<?php echo $donne['Id']; ?>">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="<?php echo $donne['id_cv'];?>">CV</a></td>
    				</tr>
            <?php           } ?>
                          </tbody>
                          </table>
                          &nbsp;
     
                    <ul class="pagination justify-content-center">
                      <li class="page-item">
            <?php           for ($i=1; $i<=$page_total; $i++) { ?>
            			 <li class="page-item"><a class="page-link" href="list.php?page=<?php echo $i; ?>"><?php echo "$i"; ?></a>
            <?php           }?>
            </li>
            </ul>
    			  </div>
          </div>
          </div>
            </div>
          </div>
          </form>
        </div>
    	</main>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    </body>
    <div class="footer">
          <div class="footer-copyright text-center py-3"><hr class="my-4" style="margin: auto;width: 40%;"></br><p class="text-muted">© <?php echo date("Y"); ?> Codé par Ethan Selleron</small></p></div>
    </div>
    </div>
    </html>

    Ainsi que le CSS complet de ma page :

    Code CSS : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    page-content {
      position: relative;
      width: 100%;
      max-width: 100%;
      height: 100%;
      margin-left: auto;
      margin-right: auto;
      min-height: 100%;
      min-height: 100vh;
      max-height: 100%;
      display: flex;
      align-items: center;
    }
     
    body {
      background-color: #E8ECEF;
      width: 100%;
      height: 100%;
      margin-left: auto;
      margin-right: auto;
    }
     
    body>.container {
      padding-top: 60px;
    }
     
    img {
      width: 25%;
    }
     
    .navbar {
      border-bottom-style: solid;
      border-bottom-color: white;
    }
     
    .table {
      max-width: 100%;
      table-layout: fixed;
      align-items: center;
      margin-left: auto;
      margin-right: auto;
      width: 80%;
    }
     
    th {
      font-size: 12.5px;
      max-width: 80px;
    }
     
    td {
      max-width: 80px;
    }
     
    td:hover {
      text-overflow: clip;
    }
     
    .th:hover {
      overflow: visible;
      white-space: normal;
      height: auto;
    }
     
    tr {
      font-size: 11px;
      text-align: center;
    }
     
    .footer {
      bottom: 0px;
    }
     
    .options {
      width: 90%;
      border-radius: 7px;
      margin-left: 5%;
      position: relative;
    }
     
    .form-control {
      position: absolute;
      width: 20%;
      margin-left: 80%;
    }
     
    .has-search .form-control {
      padding-left: 2.375rem;
    }
     
    .has-search .form-control-feedback {
      position: absolute;
      z-index: 2;
      display: block;
      width: 2.375rem;
      height: 2.375rem;
      line-height: 2.375rem;
      text-align: center;
      pointer-events: none;
      color: #aaa;
      margin-left: 80%;
    }
     
    .main {
      margin-top: -50px;
    }
     
    .pagination {
      width: 100%;
    }
     
    .pagination a {
      text-decoration: none;
      color: black;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    }
     
    .container {
      width: 100%;
    }
     
    tbody {
      display: sticky;
      overflow-y: scroll;
    }

    En vous remerciant,

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    dans le forum CSS, il faut montrer le code HTML généré (SANS PHP) : "Ctrl"+"U"

  3. #3
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2019
    Messages
    83
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2019
    Messages : 83
    Par défaut
    D'accord excuse moi jreaux, je viens d'essayer de faire CMD + U / CTRL + U car je suis sous mac, où dois-je le faire ?
    Je suis sous atom, je viens de tester de le faire aussi sur le formulaire de création de poste ici et ça me souligne juste le texte..?

    Désolé je n'étais pas au courant qu'il y avait possibilité d'effectuer cette action..

  4. #4
    Invité
    Invité(e)
    Par défaut
    1- Ben, quand tu affiches la page dans le navigateur (Safari ?) !
    "Mac afficher le code source"

    • Faire un clic droit puis sélectionner "Code source de la page".
    • Ou utiliser le raccourci clavier Ctrl + U , ou Cmd + U sur OS X.



    2- On avait fait ça tantôt (JS) : https://codepen.io/jreaux62/pen/eLoOKM

  5. #5
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2019
    Messages
    83
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2019
    Messages : 83
    Par défaut
    Ah ouuui excuse moi voici le code HTML :

    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    <!DOCTYPE html>
    <html>
    <head>
    	<title>PA - Liste des utilisateurs</title>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
      <link rel="stylesheet" href="css/list.css">
      <meta name="viewport" content="width=device-width, initial-scale=1">
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<link rel="icon" href="https://www.proactiveacademy.fr/wp-content/uploads/2018/01/cropped-favicon-32x32.png" sizes="32x32" />
      <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">
    </head>
    <body class="d-flex flex-column justify-content-center">
      <div id="page-content">
        <nav class="navbar navbar-expand-md bg-dark navbar-dark">
          <a class="navbar-brand"><img src="http://www.proactiveacademy.fr/wp-content/uploads/2018/01/p-proactive-1.png" class="img-fluid" alt="Responsive image"></a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="collapsibleNavbar">
            <ul class="navbar-nav mx-auto">
              <li class="nav-item">
                            <a class="nav-link" href="inscrits.csv"><i class="fas fa-download"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="add.php"><i class="fas fa-user-plus"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="add_csv.php"><i class="fas fa-users"></i></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt"></i></a>
              </li>
            </ul>
          </div>
                  <span class="navbar-text right-align" style="text-align: right;">Bienvenue, Ethan</span>
        </nav>
    	</header>
      	<main class="flex-fill justify-content-center align-items-center">
            <div class="main"><br/><br/>
                <div class="container-fluid"><br/><br/>
                  <div class="options">
                    <div class="form-group has-search">
                      <span class="fa fa-search form-control-feedback"></span>
                    <form method="post" action="list.php">
                    <div class="searchbar"><input type="text" class="form-control" value="Rechercher un utilisateur" name="Search" onclick="this.value='';"></div></form>
                    <form method="post" action="list.php">
                      <input type="submit" class="btn btn-danger" style="width: 130px;" value="Supprimer" name="supprimer">
                    </div>
                  </div>
                <div class="row h-1">
                    <div class="col-sm-13 mx-auto">
                  <table class="table table-striped table-responsive table-hover" id="myTable">
                  <thead class="thead-dark" style="width:10%;">
                    <tr>
                        <th style="width:2%;" id="Choix"></th>
                        <th id="Nom" class="selection" data-tri="1" data-type="num">NOM</th>
                        <th id="Prenom">PRÉNOM</th>
                        <th id="Sexe">SEXE</th>
                        <th id="Telephone" >TELEPHONE</th>
                        <th id="E-mail">EMAIL</th>
                        <th id="Code-Postale" scope="col">CODE POSTALE</th>
                        <th id="Adresse" scope="col">ADRESSE</th>
                        <th id="Ville" scope="col">VILLE</th>
                        <th id="QPV" scope="col">QPV</th>
                        <th id="DernierDiplome" scope="col">DERNIER DIPLÔME</th>
                        <th id="Formationvise" scope="col">FORMATION VISEE</th>
                        <th id="Specialitee" scope="col">SPECIALITEE</th>
                        <th id="Niveau" scope="col">NIVEAU DE FORMATION VISE</th>
                        <th id="Metier" scope="col">METIER</th>
                        <th id="Contratvise" scope="col">CONTRAT VISE</th>
                        <th id="Rythme" scope="col">RYTHME D'ALTERNANCE</th>
                        <th id="Structure" scope="col">STRUCTURE</th>
                        <th id="Entreprise" scope="col">ENTREPRISE</th>
                        <th id="Commentaires" scope="col">COMMENTAIRES</th>
                        <th id="Upload" style="width:6%" scope="col">UPLOAD</th>
                        <th style="width:7%;" id="Edit" scope="col">MODIFICATION</th>
                        <th id="CV" style="width:5%;" scope="col"></th>
                    </tr>
                  </thead>
                  <tbody>
    				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="41" /></td>
    					<td class="w-25">TEST</td>
    					<td class="w-25">TEST</td>
    					<td>Homme</td>
    					<td></td>
    					<td>test@test.fr</td>
    					<td></td>
              <td>TEST RUE DU TEST</td>
              <td>TEST</td>
    					<td></td>
              <td>LICENCE</td>
              <td>DUT</td>
              <td>Achat/Logistique/Supply Chain</td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td>lol</td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=41">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=41">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="cv/CDC_OutilPA.docx">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="40" /></td>
    					<td class="w-25">Lol</td>
    					<td class="w-25">Test</td>
    					<td>Homme</td>
    					<td>53851</td>
    					<td>test@test.fr</td>
    					<td>75007</td>
              <td>200 rue cardinet</td>
              <td>Lol</td>
    					<td>300m</td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=40">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=40">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="39" /></td>
    					<td class="w-25">Exlol</td>
    					<td class="w-25">Julien</td>
    					<td>Femme</td>
    					<td>99953851</td>
    					<td>test@test.fr</td>
    					<td>92000</td>
              <td>100 rue cardinet</td>
              <td>Lille</td>
    					<td>Non
    </td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=39">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=39">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="38" /></td>
    					<td class="w-25">Selleron</td>
    					<td class="w-25">Ethan</td>
    					<td>Homme</td>
    					<td>621753851</td>
    					<td>test@test.fr</td>
    					<td>75017</td>
              <td>111 rue cardinet</td>
              <td>Paris</td>
    					<td>Oui
    </td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=38">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=38">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="37" /></td>
    					<td class="w-25">Lol</td>
    					<td class="w-25">Test</td>
    					<td>Homme</td>
    					<td></td>
    					<td>test@test.fr</td>
    					<td>99999</td>
              <td>200 rue cardinet</td>
              <td>Lol</td>
    					<td>300m</td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=37">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=37">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="36" /></td>
    					<td class="w-25">Exlol</td>
    					<td class="w-25">Julien</td>
    					<td>Femme</td>
    					<td>99953851</td>
    					<td>test@test.fr</td>
    					<td>92000</td>
              <td>100 rue cardinet</td>
              <td>Lille</td>
    					<td>Non
    </td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=36">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=36">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="35" /></td>
    					<td class="w-25">Selleron</td>
    					<td class="w-25">Ethan</td>
    					<td>Homme</td>
    					<td>621753851</td>
    					<td>test@test.fr</td>
    					<td>75017</td>
              <td>111 rue cardinet</td>
              <td>Paris</td>
    					<td>Oui
    </td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=35">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=35">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="53" /></td>
    					<td class="w-25">ZFEFZEFZEFZ</td>
    					<td class="w-25">TESTTTTT</td>
    					<td></td>
    					<td></td>
    					<td></td>
    					<td></td>
              <td></td>
              <td></td>
    					<td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=53">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=53">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="54" /></td>
    					<td class="w-25">ekfzeifkzefize</td>
    					<td class="w-25">fezfizeifze</td>
    					<td>Homme</td>
    					<td></td>
    					<td></td>
    					<td></td>
              <td></td>
              <td></td>
    					<td>Oui</td>
              <td>BAC</td>
              <td>DUT</td>
              <td>Assistanat/Secrétariat/Administratif</td>
              <td>BAC +4</td>
              <td>Tertiaire - Management D'entreprise</td>
              <td>PROFESSIONNALISATION</td>
              <td>3S/1S</td>
              <td>TEST</td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=54">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=54">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
            				<tr>
    					<td class="w-25"><input type="checkbox" name="delete[]" value="55" /></td>
    					<td class="w-25">TESTTTT</td>
    					<td class="w-25">ETHANNNNN</td>
    					<td></td>
    					<td></td>
    					<td>test@test.fr</td>
    					<td></td>
              <td>111 rue du cardinet</td>
              <td>Paris</td>
    					<td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=55">Upload</a></td>
    					<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=55">Editer</a></td>
              <td><a class="btnEdit btn btn-primary btn-sm" href="">CV</a></td>
    				</tr>
                                  </tbody>
                          </table>
                          &nbsp;
     
                    <ul class="pagination justify-content-center">
                      <li class="page-item">
                    			 <li class="page-item"><a class="page-link" href="list.php?page=1">1</a>
                    			 <li class="page-item"><a class="page-link" href="list.php?page=2">2</a>
                    			 <li class="page-item"><a class="page-link" href="list.php?page=3">3</a>
                    			 <li class="page-item"><a class="page-link" href="list.php?page=4">4</a>
                    </li>
            </ul>
    			  </div>
          </div>
          </div>
            </div>
          </div>
          </form>
        </div>
    	</main>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    </body>
    <div class="footer">
          <div class="footer-copyright text-center py-3"><hr class="my-4" style="margin: auto;width: 40%;"></br><p class="text-muted">© 2019 Codé par Ethan</small></p></div>
    </div>
    </div>
    </html>

    Pendant ce temps là je tente avec ta technique, je te tiens au courant.

    EDIT : Après tests, il semblerait que ça me duplique mon tableau mais ça ne fonctionne pas, y aurait-il pas une solution plus simple ?

  6. #6
    Invité
    Invité(e)
    Par défaut
    1- Le HTML :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
      <div class="table-wrap table-thead-fixed" data-nbreligne="12">
        <table>
          <thead>
    ...
          </thead>
          <tbody>
    ...
          </tbody>
        </table>
      </div>
    2- Il faut ce bout de CSS :
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    /* ---------------------- */
    /* table avec entete fixe */
    /* ---------------------- */
    .table-thead-fixed {
      position: relative;
      overflow: hidden;
    }
    .theader-fixed {
      z-index: 1;
      position: absolute;
      overflow: hidden;
      background:#fff;
    }
    .tbody-scroll {
      position: relative;
      overflow: auto;
      margin-bottom: 5px;
    }
    3-
    Code JavaScript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    "use strict";
    // ----------
    function table_thead_fixed() 
    {
    	// on peut avoir plusieurs tables
    	let tableDivWraps = document.querySelectorAll(".table-thead-fixed");
    	tableDivWraps.forEach(function(tableDivWrap) 
    	{
    		// ----------
    		// table avec entete fixe
    		let tableRef = tableDivWrap.children[0]; // table
    		// ----------
    		// on entoure la table d un div
    		let tableBodyScroll = document.createElement("div");
    		tableBodyScroll.className += "tbody-scroll"; // "tbody-scroll"
    		tableDivWrap.insertBefore(tableBodyScroll, tableRef);
    		tableBodyScroll.appendChild(tableRef);
    		// ----------
    		// entete fixe : copie (clone) de la table
    		let tableHeadFixed = document.createElement("div"); // "theader-fixed"
    		tableHeadFixed.className += "theader-fixed";
    		tableHeadFixed.appendChild(tableRef.cloneNode(true));
    		tableDivWrap.prepend(tableHeadFixed);
    		// ----------
    		// SPECIAL : cas particulier
        // on change l id "pointsTable" -> "pointsTable2" (id sur le <tbody>)
    //		document.querySelector('.theader-fixed #pointsTable').id = 'pointsTable2';
    		// ----------
    	});
    	// ----------
    	// ajustement hauteur de scroll propre
    	table_thead_fixed_resize();
    }
    // --------------------
    // Redimensionnement de la fenêtre (horizontal)
    function table_thead_fixed_resize() 
    {
    	// on peut avoir plusieurs tables
    	let tableDivWraps = document.querySelectorAll(".table-thead-fixed");
    	tableDivWraps.forEach(function(tableDivWrap) 
    	{
    		let nbLigne = tableDivWrap.dataset.nbreligne !== undefined ? tableDivWrap.dataset.nbreligne : 12; // défaut 12 (A ADAPTER)
    		// ----------
    		let tableHeadFixed = tableDivWrap.children[0];
    		let tableBodyScroll = tableDivWrap.children[1];
    		let tableRef = tableBodyScroll.children[0];
    		// ----------
    		// calcul hauteur scroll-barre-X
    		let hScrollBar = tableBodyScroll.offsetHeight - tableBodyScroll.clientHeight;
    		// ----------
    		// nombre de lignes à montrer
    		let nbLigneToShow = Math.min(nbLigne, tableRef.rows.length) + 1;
    		let rect1 = tableRef.rows[0].getBoundingClientRect();
    		let rect2 = tableRef.rows[nbLigneToShow].getBoundingClientRect();
    		tableBodyScroll.style.height = rect2.top - rect1.top + hScrollBar + "px";
    		// ----------
    		// calcul pour réajustement
    		let hEntete = tableRef.tHead.offsetHeight;
    		// ----------
    		// calcul largeur scroll-barre-Y
    		let wScrollBar = tableBodyScroll.offsetWidth - tableBodyScroll.clientWidth;
    		// ----------
    		// réajustement du header fixe
    		tableHeadFixed.style.height = hEntete + "px";
    		tableHeadFixed.style.width = "calc(100% - " + wScrollBar + "px)";
    		// ----------
    		// synchronisation des scrolls
    		tableBodyScroll.onscroll = function() {
    		tableHeadFixed.style.marginLeft = -this.scrollLeft + "px";
    		};
    		// ----------
    	});
    }
     
    // Activation :
    window.onload = function(){
      table_thead_fixed();
    }
    // Redimensionnement de la fenêtre
    window.onresize = function(){
      table_thead_fixed_resize();
    }
    Dernière modification par Invité ; 12/09/2019 à 15h50.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. <table> avec <thead> en position absolue et <tbody> dans un ascenseur
    Par Benduroy dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 21/11/2012, 16h35
  2. Gestion position div avec scroll
    Par ciran dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 30/09/2011, 13h48
  3. [Access] Nom d'une table avec un espace dans SQL
    Par Corsaire dans le forum Langage SQL
    Réponses: 7
    Dernier message: 21/04/2006, 15h50
  4. [syntaxe]Creation table avec nom dynamique
    Par ZuZu dans le forum MS SQL Server
    Réponses: 6
    Dernier message: 23/09/2004, 18h01
  5. Création de table avec index
    Par Seb7 dans le forum Requêtes
    Réponses: 2
    Dernier message: 10/04/2003, 16h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo