JSFiddle - React, Tailwind, and code Playground
by Victor
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div class="field">
<div class="test"></div>
</div>
SCSS
.field {
width: 100%;
height: 100%;
background: black;
position: fixed; top: 0;
left: 0;
background: url('http://loremflickr.com/320/240') center center;
background-size: contain;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ff1a00+0,ff7b00+100 */
background: rgb(255,26,0); /* Old browsers */
background: -moz-linear-gradient(-45deg, #00bcf2 0%, rgb(0, 141, 180) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, #00bcf2 0%,rgb(0, 141, 180) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, #00bcf2 0%,rgb(0, 141, 180) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff1a00', endColorstr='#ff7b00',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
/* background: black; */
}
.test {
position: fixed;
top: 0;
left: 0;
width: 4px;
height: 4px;
margin: 10px;
border-radius: 200px;
/* background: rgba(255,255,150,0.33); */
animation: ripple 10s infinite;
animation-timing-function: ease-in-out;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#99fbff+0,5593e0+36,5593e0+36,5593e0+60,99fbff+100&1+0,0+100 */
background: -moz-radial-gradient(center, ellipse cover, rgba(153,251,255,1) 0%, rgba(85,147,224,0.64) 36%, rgba(85,147,224,0.4) 60%, rgba(153,251,255,0) 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, rgba(153,251,255,1) 0%,rgba(85,147,224,0.64) 36%,rgba(85,147,224,0.4) 60%,rgba(153,251,255,0) 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, rgba(153,251,255,1) 0%,rgba(85,147,224,0.64) 36%,rgba(85,147,224,0.4) 60%,rgba(153,251,255,0) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#99fbff', endColorstr='#0099fbff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
...
JavaScript
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
$(document).ready(function(){
//dims
var winH = $(window).height();
var winW = $(window).width();
var count = 100;
var field = document.querySelector('field');
for(i=0; i <= count; i++){
var sameRan = getRandom(20,80);
var floaterHTML = '<div class="test test-'+ i +'" style="left:' + getRandom(0,winW) + 'px; top: ' + getRandom(0, winH) + 'px; animation: ripple ' + getRandom(20,100) +'s infinite; width:'+ sameRan +'px ; height: '+ sameRan +'px;"></div>';
$('.field').append(floaterHTML);
};
$(window).on('resize', function(){
console.log('testing');
winH = $(this).height();
winW = $(this).width();
$('.test').each(function(i){
$(this).css('left', getRandom(-50,winW) + 'px');
$(this).css('top', getRandom(-50,winH) + 'px');
})
});
})
window.onresize = function() {
};
window.onresize();