JSFiddle - React, Tailwind, and code Playground
HTML
<div id="fixedBox">Меню</div>
<br />
<script>
for (i=1; i<101; i++) document.write('<br />');
</script>
CSS
#fixedBox{
width:100%;
position:fixed;
margin-top:120px;
min-height:1600px;
}
JavaScript
jQuery(document).ready(function(){
function getScrollTop() {
var scrOfY = 0;
if( typeof( window.pageYOffset ) == "number" ) {
scrOfY = window.pageYOffset;
} else if( document.body
&& ( document.body.scrollLeft
|| document.body.scrollTop ) ) {
scrOfY = document.body.scrollTop;
} else if( document.documentElement
&& ( document.documentElement.scrollLeft
|| document.documentElement.scrollTop ) ) {
scrOfY = document.documentElement.scrollTop;
}
return scrOfY;
}
jQuery(window).scroll(function() {
fixPaneRefresh();
});
function fixPaneRefresh(){
if (jQuery("#fixedBox").length) {
var top = getScrollTop();
if (top < 120) jQuery("#fixedBox").css("margin-top",120-top+"px");
else jQuery("#fixedBox").css("margin-top","0");
}
}
});