JSFiddle - React, Tailwind, and code Playground

by Sean Cannon

CSS

body {
    overflow:hidden;
}
div {
    position:absolute;
}

JavaScript

var i        = 0,
    maxNodes = 5000,
    node, nodes, frag, max, radius, margin, size, opacity;
 
/**
 * Generate a random hex color code. 
 * Thanks to Paul Irish for posting this (16777215 == ffffff in decimal)
 * http://www.paulirish.com/2009/random-hex-color-code-snippets/
 * 
 * @returns {String} Our hex color code
 */
function hex() {
    return '#' + Math.floor(Math.random() * 16777215).toString(16).toUpperCase();
}
 
/** 
 * Returns a random number within a range.
 * @param   {Int} min
 * @param   {Int} max
 * @returns {Int} Our random number
 */
function rand (min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
 
// Create a DOM node that isn't part of the DOM tree. 
// https://developer.mozilla.org/en-US/docs/Web/API/document.createDocumentFragment
frag = document.createDocumentFragment();
 
// Append a bunch of empty divs to the document fragment
for (; i < maxNodes; i++) {
    node = document.createElement('div');
    frag.appendChild(node);
}
 
// Append the fragment to the body
document.body.appendChild(frag);

nodes = document.getElementsByTagName('div');
for (i = 0; i < maxNodes; i++) {
    // Random size, shape, and styling
    radius  = rand(2,20);
    size    = rand(5,25);
    shadow  = rand(2,7);
    opacity = rand(1,20) * .1;
    
    // Random color
    nodes[i].style.backgroundColor    = hex();
 
    // Size it
    nodes[i].style.width              = size + 'px';
    nodes[i].style.height             = size + 'px';
 
    // Position it
    nodes[i].style.top                = rand(0,500) + 'px';
    nodes[i].style.left               = rand(0,500) + 'px';
 
    // Cross-browser shadow
    nodes[i].style.boxShadow          = shadow + 'px ' + shadow + 'px ' +shadow + 'px ' + ' rgba(0,0,0,' + opacity + ')';
    nodes[i].style.MozBoxShadow       = shadow + 'px ' + shadow + 'px ' +shadow + 'px ' + ' rgba(0,0,0,' + opacity + ')';
    nodes[i].style.WebkitBoxShadow    = shadow + 'px ' + shadow + 'px ' +shadow + 'px ' + '...