JSFiddle - React, Tailwind, and code Playground
HTML
<div id="getScrolled">This div is going to scroll</div>
<div id="getFixed">This div is going to be fixed</div>
CSS
body { height: 2000px; ; }
#getFixed, #getScrolled { color: #c00; font: bold 15px arial; padding: 10px; margin: 10px; border: 1px solid #c00; width: 200px; }
JavaScript
$(window).scroll( function() {
var $cache = $('#getFixed')
($(window).scrollTop() > 55) ?
$cache.css({'position': 'fixed', 'top': '0px'})
:
$cache.css({'position': 'relative', 'top': 'auto'});
});