Table Thead Fixed Tbody Scroll Css Code Example


Example: scroll tbody fixed thead


table {
width: 100%;
}

table, td {
border-collapse: collapse;
border: 1px solid #000;
}

thead {
display: table; /* to take the same width as tr */
width: calc(100% - 17px); /* - 17px because of the scrollbar width */
}

tbody {
display: block; /* to enable vertical scrolling */
max-height: 200px; /* e.g. */
overflow-y: scroll; /* keeps the scrollbar even if it doesn't need it; display purpose */
}

th, td {
width: 33.33%; /* to enable "word-break: break-all" */
padding: 5px;
word-break: break-all; /* 4. */
}

tr {
display: table; /* display purpose; th's border */
width: 100%;
box-sizing: border-box; /* because of the border (Chrome needs this line, but not FF) */
}

td {
text-align: center;
border-bottom: none;
border-left: none;
}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable