richarddunnebsc
Active Coder
I have a table with 10 columns. I want the header row, first three columns and the last column sticky.
I have managed to get the header row and first column sticky with the code below.
I have tried using nth-child(), but to no avail.
Any help greatly appreciated
I have managed to get the header row and first column sticky with the code below.
CSS:
table{
table-layout: fixed;
width: 100%;
height: 100%;
}
table thead tr th{
width: 150px;
}
table tbody tr td{
text-align: center;
}
thead tr > th {
background:#ccc;
position: sticky;
padding:.5rem;
z-index:1;
top: 0;
}
thead tr > :first-child,
thead tr > :last-child {
z-index:2;
left:0;
top:0;
}
td {
text-align:center;
}
tbody tr > :first-child,
tbody tr > :last-child {
background:#ddd;
position: sticky;
z-index:3;
left:0;
}
Any help greatly appreciated
