JSFiddle - React, Tailwind, and code Playground

by kodjoe mambi

HTML

<div id="el">Element</div>

<div class="body"></div>

CSS

#el{
    min-height: 200px;
    background: red;
    position: fixed;
    top: 0;
}

.body{
    min-height: 2000px;
    background: green;
}

JavaScript

var $element = $('#el');

$(window).scroll(function() {
    if($(this).scrollTop() > 0) {
        $element.hide(100);
    } else {
        $element.show(100);
    }
});