JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr class="relative" id="header">
<td>header
</td>
</tr>
<tr id="content">
<td>table content
</td>
</tr>
</table>
CSS
td{
border:1px solid black;
}
#content{
height:400px;
}
table{
margin-top:150px;
}
.relative{
position:relative;
}
.fixed{
position:fixed;
top:0;
}
JavaScript
$(function () {
$(window).scroll(function() {
if ($(window).scrollTop() > 140) {
$("#header").addClass("fixed");
} else {
$("#header").removeClass("fixed");
}
});
});