JSFiddle - React, Tailwind, and code Playground

HTML

<div class="content"></div>
<div class="fixme"> STICKY</div>
<div class="content2"></div>
<div class="object2"> object 2</div>

CSS

body { height: 3000px; }

.content { height: 200px; }

.content2 { height: 20px; }

.fixme {background-color:green; text-align:center; color:white; position: relative; width: 100%; z-index:999;}

.object2 {background-color:red; text-align:center; color:white; position: relative; width: 100%; }

JavaScript

var fixmeTop = $('.fixme').offset().top;
    $(window).scroll(function() {
        var currentScroll = $(window).scrollTop();
        if (currentScroll >= fixmeTop) {
            $('.fixme').css({
                position: 'fixed',
                top: '0',
                left: '0'
            });
        } else {
            $('.fixme').css({
                position: 'static'
            });
        }
    });