tableau html avec défilement vertical à l'intérieur tbody

Je fais des efforts pour une barre de défilement verticale à l'intérieur tbody avec un en-tête fixe. J'ai essayé la solution fournie dans le lien.

Tableau HTML avec 100% de largeur, avec défilement vertical à l'intérieur tbody

table {
width: 100%;
border-spacing: 0;
}

thead, tbody, tr, th, td { display: block; }

thead tr {
/* fallback */
width: 97%;
/* minus scroll bar width */
width: -webkit-calc(100% - 16px);
width:    -moz-calc(100% - 16px);
width:         calc(100% - 16px);
}

tr:after {  /* clearing float */
content: ' ';
display: block;
visibility: hidden;
clear: both;
}

tbody {
height: 100px;
overflow-y: auto;
overflow-x: hidden;
}

tbody td, thead th {
width: 19%;  /* 19% is less than (100% /5 cols) = 20% */
float: left;
}

Il fonctionne très bien si la barre de défilement apparaît.Mais si les lignes sont peu nombreux et la barre de défilement ne s'affiche pas, alors thead n'est pas aligné avec tbody. Comment puis-je résoudre le problème avec le css?

tableau html avec défilement vertical à l'intérieur tbody

  • Pouvez-vous insérer un jsfiddle dans le post?
InformationsquelleAutor Nagendra | 2016-06-28