JSFiddle - React, Tailwind, and code Playground
by vicky081
HTML
<div class="theme-bg"></div>
JavaScript
function runParticles() {
$('.theme-bg').prepend('<div class="particles" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; min-height: 100%; background-image: url(images/particle1.png); z-index: 1; background-repeat: no-repeat; background-position: 0px 0px;"></div>');
var randParXa = Math.floor(Math.random() * $('.theme-bg').width());
var randParXb = Math.floor(Math.random() * $('.theme-bg').width());
var randParY = $('.theme-bg').height();
var randParSpd = Math.floor(Math.random() * (2500 - 1550) + 1550);
$('.particles').css({'background-position':randParXa+'px 0px'});
$('.particles').animate({
'background-position':randParXb+'px '+randParY+'px',
'opacity':0.0
}, randParSpd, function() {
$(this).remove();
runParticles();
});
}
runParticles();