My goal is to design a table with frozen threads and vertically oriented labels in the header. I have made an attempt at implementing this below, but as a newcomer to CSS, I am facing several challenges.
One issue I've encountered with my solution is that it's not immediately clear that there are more rows to scroll through, as the scrollbar remains hidden until you start scrolling. Is there a way to keep the scrollbar visible at all times?
There is also a large gap above where the party names are displayed in the header. While adjusting the values in "th.vertical" can increase this gap, I'm struggling to eliminate it entirely. How can I make the header only as tall as the text it contains?
Lastly, I would like the vertical text in the header to be centered in relation to the column values, but I haven't been able to achieve this yet. Any suggestions on how I could do this?
Additionally, I want to enable sorting on any column
table thead tr {
display: block;
}
table th,
table td {
width: 75px; //fixed width
}
div.vertical {
margin-left: -100px;
position: absolute;
width: 210px;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
/* Safari/Chrome */
-moz-transform: rotate(-90deg);
/* Firefox */
-o-transform: rotate(-90deg);
/* Opera */
-ms-transform: rotate(-90deg);
/* IE 9 */
}
th.vertical {
height: 60px;
line-height: 14px;
padding-bottom: 100px;
text-align: left;
}
table tbody {
display: block;
height: 500px;
overflow: auto;
}
<table class='vrt-header'>
<thead>
<tr>
<th></th>
<th class="vertical">
<div class="vertical">Republican</div>
</th>
<th class="vertical">
<div class="vertical">Democrat</div>
</th>
<th class="vertical">
<div class="vertical">Libertarian</div>
</th>
<th class="vertical">
<div class="vertical">Green</div>
</th>
</tr>
</thead>
<tbody>
<!-- Data goes here -->
</tbody>
</table>