JSFiddle - React, Tailwind, and code Playground
HTML
<div id="fixedBox">Меню</div>
<br />
<script>
for (i=1; i<101; i++) document.write('<br />');
</script>
CSS
body {
min-height:1600px;
}
#fixedBox{
width:100%;
background-color:green;
position:absolute;
top:120px;
height:100px;
}
JavaScript
$(function() {
$( document ).scroll( (function() {
var doc = $( document );
var div = $( '#fixedBox' );
var maxOffset = div.offset().top;
return function() {
var docScrollTop = doc.scrollTop();
if ( docScrollTop > maxOffset ) {
div.css({ top: docScrollTop });
}
}
}()));
});