I am trying to get the dimensions of the viewport and then fill it squares so that they perfect cover the whole viewport. There must be a better way than my current code (below). Perhaps there is a way to find an easily divisible number for the denominator of this line var boxWidthHeight = wrapperArea / 30000;
?
$(document).ready(function() {
var wrapperWidth = $(window).width();
var wrapperHeight = $(window).height();
$('.wrapper').css('width', wrapperWidth);
$('.wrapper').css('height', wrapperHeight);
var wrapperArea = wrapperWidth * wrapperHeight;
var boxWidthHeight = wrapperArea / 30000;
var boxWidthHeight = parseInt(boxWidthHeight);
var boxArea = boxWidthHeight * boxWidthHeight;
var boxCount = wrapperArea / boxArea;
for(var i = 0; i < boxCount; i++) {
$('.wrapper').append('<div class="box"></div>');
}
$(".box").css({ width: boxWidthHeight, height: boxWidthHeight });
});