JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<div class="container" style="height: 200px;background: #ccc">
</div>
JavaScript
var width=$('.container').innerWidth();
var height=$('.container').innerHeight();
(function generate(){
// vary size for fun
for (i = 0; i < 15; i++) {
var divsize =12;
var color = '#'+ Math.round(0xffffff * Math.random()).toString(16);
$newdiv = $('<div/>').css({
'width':divsize+'px',
'height':divsize+'px'
});
// make position sensitive to size and document's width
var posx = (Math.random() * (width - divsize)).toFixed();
var posy = (Math.random() * (height - divsize)).toFixed();
$newdiv.css({
'position':'absolute',
'left':posx+'px',
'top':posy+'px',
'float':'left'
}).appendTo( '.container' ).html(Math.floor(Math.random()*9));
}
})();