JSFiddle - React, Tailwind, and code Playground

HTML

<div id="main">
    <div id="thing">
    </div>
</div>

CSS

#main { height: 400px; }
#thing { position: fixed; top: 300px; height: 50px; width: 50px; display: inline-block; background-color: green; }

JavaScript

setInterval(function(){ $('#thing').animate({ top: '-=10px'}, 300).animate({top: '+=10px' }, 300); }, 1000);