JSFiddle - React, Tailwind, and code Playground

by serio

CSS

body
{
    position: relative;   
}

JavaScript

var img_url = 'http://images1.wikia.nocookie.net/__cb20110402203034/fallout/images/thumb/c/c1/Tumbleweed.png/482px-Tumbleweed.png';

function addImage() {

    var img = {};
    var width_height = returnRandomRange( 80, 200 );
    
    img.xPos = returnRandomRange( 0, 20 );
    img.yPos = returnRandomRange( 0, 80 );
    
    img.speed = returnRandomRange( 3, 8 );
    img.rot = 0;
    img.el = document.createElement("img");
    img.el.src = img_url;
    img.el.width = width_height;
    img.el.height = width_height;
    $(img.el).appendTo('body');

    img.interval = setInterval(function() {
        
        img.rot++;
        if(img.rot >= 360 ) img.rot = 0;
        
        var css = '-webkit-transform: rotate(' + img.rot + 'deg);';
        css += '-moz-transform: rotate(' + img.rot + 'deg);';
        css += 'position: absolute;';
        css += 'left: ' + img.xPos + 'px;';
        css += 'right: ' + img.yPos + 'px;';
        
        $( img.el ).attr( 'style', css );
    }, img.speed);
}

function returnRandomRange( min, max )
{
    var n = max - min + 1;
    return Math.round(Math.random() * n + min); 
}

$(function() {
    addImage();
});