JSFiddle - React, Tailwind, and code Playground

by nikolya223

HTML

<div class="layer1 paralax">
   <div>
   </div> 
</div>
<div class="layer2 paralax">
   <div>
   </div> 
</div>

CSS

body,html{
    width: 100%;
    height: 100%;
}
.paralax>div{
    height: 3000px;
    
}
.layer1,.layer2,.layer3{
    background: rgba(0,0,0,0.2);
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    overflow: hidden;
    height: 100%;
} 

.layer1{
    z-index: 1;
}
.layer2{
    z-index: 2;
}
.quadra{
    width: 50px;
    height: 50px;
    position: absolute;
    background: black;
}
.circle{
    width: 50px;
    height: 50px;
    position: absolute;
    background: red;
    border-radius: 50px;
    
}

JavaScript

var paralax = {};
    paralax.set ={};
    paralax.set.quadCount = 100;
(function(){
    for ( i = 0;i< paralax.set.quadCount;i++){
        var top  = Math.floor(Math.random() * (3000 - 0 + 1)) + 0;
        var left = Math.floor(Math.random() * (screen.availWidth - 0 + 1)) + 0;
        $(".layer1>div").append('<div class="quadra" style="top:'+top+'px;left:'+left+'px;"></div>');
        var top  = Math.floor(Math.random() * (3000 - 0 + 1)) + 0;
        var left = Math.floor(Math.random() * (screen.availWidth - 0 + 1)) + 0;
        $(".layer2>div").append('<div class="circle" style="top:'+top+'px;left:'+left+'px;"></div>')
    }
    $(".layer1").animate({scrollTop:3000},5000)
})();