JSFiddle - React, Tailwind, and code Playground

HTML

<div id="holder"></div>

CSS

.box {
    width:50px;
    height:50px;
    background:#eee;
    position:absolute;
    border:1px solid;
}

JavaScript

var arr = [1,2,3,4,5,6,7,8,9]
, n = -1;

$.map(arr, function(val, key) {
    var box = $(".box"),
    height = box.height() + 20,
    width = box.width() + 20,
    len = box.length;
    $("<div>", {
        "class":"box",
        "id":"box" + key,
        "css": {
            "left": key < 3 
                    ? (len * width)
                    : box.eq(++n).css("left"),
            
            "top": key < 3 
                   ? 0 
                   : key < 6
                     ? height 
                     : (2 * height)
        }
    }).appendTo("#holder")
})