JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container"></div>
<img src="http://www.part.lt/img/58c51afeddea4284c502eac5474741f3429.png" />
CSS
.container{
position:relative;
width: 345px;
height: 417px;
border:1px solid;
margin:10px;
float:left;
}
.shape{
position:abosule;
background: red;
border:1px solid green;
color: white;
font-size:20px;
text-align:center;
}
img{
float:left;
margin:10px;
}
JavaScript
$shape = $('<div class="shape"></div>');
$container = $(".container");
//random shape sizes
shapes = [
[rand(50, 70), rand(50, 70)],
[rand(50, 70), rand(50, 70)],
[rand(60, 70), rand(60, 70)],
[rand(60, 100), rand(60, 100)],
[rand(100, 140), rand(100, 140)],
[rand(100, 140), rand(100, 140)],
[rand(100, 140), rand(100, 140)],
[rand(140, 190), rand(140, 190)],
[rand(150, 210), rand(150, 210)]
];
used = [];
left = 0;
top = 0;
for(i = 1; i <= 3; i++){
offset = rand(0, 8);
width = shapes[offset][0];
height = shapes[offset][1];
$container.append(
$shape.css({
width: width,
height: height,
top: top,
left: left,
zIndex: i
})
.text(i)
.clone()
);
//increase top offset
top += shapes[offset][1];
}
function rand(from, to){
return Math.floor((Math.random()*to)+from);
}