How do I keep #first
at the top?
<div class="table">
<table class="maintable">
<tbody>
<tr id="first">
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
<tr>
<td>Hello</td>
</tr>
</tbody>
</table>
</div>
CSS Code
.table{
grid-row: 2/9;
margin-right: 32px;
margin-bottom: 32px;
overflow: scroll;
}
tr{
height: 61px;
}
table{
width: 100%;
border-collapse: collapse;
}
#first{
position: fixed;
}
tr:nth-child(odd) {
background-color: #fefefe;
}
tr:nth-child(even) {
background-color: #fafafa;
}
I've tried using <thead>
and <th>
however because my table is inside a div, which is responsive and doesn't have a set height, I've had problems.
Is there any way to do it?