JSFiddle - React, Tailwind, and code Playground

CSS

body, html {
    width: 960;
    height: 100%;
}
div.box {
    position: relative;
    width: 100px;
    height: 100px;
    background-color: orange;
}
div.exploding {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: red;
}

JavaScript

$(document).ready(function () {
    makeDiv();

    function makeDiv() {
        var numRand = Math.floor(Math.random() * 501);
        var divsize = 100;
        var posx = (Math.random() * ($('body').width() - divsize)).toFixed();
        var posy = (Math.random() * ($('body').height() - divsize)).toFixed();
        $newdiv = $("<div class='exploding'></div>").css({
            'left': posx + 'px',
                'top': posy + 'px'
        });
        $newdiv.appendTo('body').delay(2000).fadeIn(100, function () {
            //$(this).remove();
            makeDiv();
        });
    }
});