Adds a fading gradient to an overflowing HTML table element to better indicate there is more content to be scrolled.
- Table with fixed header
- Overflow scroll gradient
- Custom scrollbar
See the live example below:
$("#scrolltable").html("");
$("#cell").append("First col | Second col |
");
for (var i = 0; i < 40; i++) {
$("#scrolltable > table > tbody").append("| " + "foo" + " | " + "bar" + " |
");
}
/* Table with fixed header */
table,
thead {
width: 100%;
text-align: left;
}
#scrolltable {
margin-top: 50px;
height: 120px;
overflow: auto;
width: 200px;
}
#scrolltable table {
border-collapse: collapse;
}
#scrolltable tr:nth-child(even) {
background: #EEE;
}
#scrolltable th div {
position: absolute;
margin-top: -30px;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}
/* Overflow scroll gradient */
.overflow-scroll-gradient {
position: relative;
}
.overflow-scroll-gradient::after {
content: '';
position: absolute;
bottom: 0;
width: 240px;
height: 25px;
background: linear-gradient( rgba(255, 255, 255, 0.001), white);
pointer-events: none;
}