JSFiddle - React, Tailwind, and code Playground

by kentaromiura

HTML

<div id="container">
    <div id="header">DIV art. <a href="index.html">by Michelle Bu</a> | <a class="disappear">disappear!</a>  <a class="reappear">reappear!</a>

    </div>
</div>

CSS

/* reset */
 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    border:0;
    font-size:100%;
    font:inherit;
    vertical-align:baseline;
    margin:0;
    padding:0
}
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display:block
}
body {
    line-height:1
}
ol, ul {
    list-style:none
}
blockquote, q {
    quotes:none
}
blockquote:before, blockquote:after, q:before, q:after {
    content:none
}
table {
    border-collapse:collapse;
    border-spacing:0
}
a {
    outline: none;
}
/* firefox borders */
 a img {
    border: none;
}
/* ie img borders */

/* rns camelia */
 @font-face {
    font-family:'rnscamelia';
    src: url('skin/camelia.ttf') format('truetype');
}
html, body {
    background-color: #e2e2e2;
    text-shadow: 0px 1px 1px #ffffff;
}
/* triangles */
 .tri {
    border-color: transparent transparent transparent #d3d3d3;
    border-style: solid;
    border-width: 30px;
    height: 0px;
    width: 0px;
    position: relative;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    margin-top: -18px;
}
.btri {
    border-color: transparent transparent transparent #49a2aa;
    border-style: solid;
    border-width: 30px;
    height: 0px;
    width: 0px;
    position: relative;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    margin-top: -18px;
}
.emp {
    border-color: transparent transparent transparent transparent;
    border-style: solid;
    border-width: 30px;
    height: 0px;
    width: 0px;
    position:...

JavaScript

$(document).ready(function () {
    function generateDivs() {

        // we are going to append the code to the body
        var container = $("body");
        // we have 3 css classes that we will choose randomly
        var classes = ['tri', 'emp', 'btri']
        // since I want to keep original css I will start from 1 and loop to 20 so I can generate the correct ids
        for (var i = 1, max = 21; i < max; i++) {

            var output = ['<div id="row', i, '">'];
            // each row has 7 div in it
            for (var j = 0, jmax = 7; j < jmax; j++) {
                // ~~(Math.random() * 100) %3 will randomly return a number between 0 and 2, using 100 is purely a habit of me, you can for example use 4, this will also changes the probability a bit,
                // the double unary not operator in this case is just a smaller way to write Math.floor
                output.push('<div class=', classes[~~ (Math.random() * 100) % 3], '></div>')
            }
            output.push('</div>')
            // we will use the jQuery(html) overload to create a node which we will append to the body 
            container.append($(output.join('')))
        }
        //this selector will select all the divs with an id that starts with row
        return $('div[id^=row]').get();
    }
    var rows = generateDivs();

    function animation(options) {
        return function () {

            // this will store the interval id
            var id,
            // since pop changes the array we need to clone the original array, using slice(0) does exactly that
            clonedrows = rows.slice(0),

                interval = function () {
                    // let's get the next element
                    var next = clonedrows.pop()
                    // if undefined we clear the interval since we've finished the loop otherwise we make it disappear
                    if (!next) {
                        clearInterval(id)
                    } else {
          ...