JSFiddle - React, Tailwind, and code Playground
HTML
<div class="nav-collapse">nav nav nav </div>
CSS
body {
height: 3000px;
top: 0;
position: relative;
}
.nav-collapse {
position: relative;
top: 100px;
width: 100%;
background: whitesmoke;
height: 100px;
}
JavaScript
$(window).scroll(function () {
if ($(window).scrollTop() > 100) {
$('.nav-collapse').css('top', $(window).scrollTop());
}
}
);