JSFiddle - React, Tailwind, and code Playground

HTML

<button id="button1">Add box</button>
<div id="outer"></div>

CSS

#outer {
    position:absolute;
    white-space:nowrap;
    height:118px;
    overflow:auto;
    width:100%;
    padding:2px;
}

.box{
    display:inline-block;
    vertical-align:top;
    width:48px;
    height:48px;
    background-color:#000;
    margin-left:5px;
}

JavaScript

var number = 0;

document.getElementById("button1").addEventListener("click", pressButton, false);

function pressButton() {
    ++number;
    makeDiv(number);
};

function makeDiv(x) {
    var innerDiv = document.createElement("div");
    outer.appendChild(innerDiv);
    innerDiv.className += " box";
    innerDiv.setAttribute("id", "innerDiv" + x);
    innerDiv.setAttribute("style", "margin-top:" + Math.floor(Math.random()*51) + "px;");
};