JSFiddle - React, Tailwind, and code Playground

by jim ulle

CSS

div:nth-child(odd)
{
background: blue;
}
div:nth-child(even)
{
background: green;
}
html, body {
height: 100%;
min-height: 100%;
}
body { position: relative; margin: 0; paddding: 0; }
div { width: 100%; position: relative; }

JavaScript

$(function(){
    //add a random amount of DIV's to the page
    var numDIVs = Math.floor((Math.random() * 100) + 1);
    for (i = 0; i < numDIVs; i++) {
        $('body').append('<div></div>');
    }
    $('div').css("height",(100/$('div').length) + "%");
});