I'm trying to make a grid that will house 3 different sized containers: 1x1, 1x2 and 2x2 in a multi row/4 column grid. My goal is to have a grid in which I can populate with new elements that will fit in perfectly. The problem is that I'm using float: left on all grid elements therefor when I have a 2x2 element that does not begin in the first column, there will be empty spaces before that 2x2 item.
section {
width: 50%;
}
.item {
float: left;
}
img {
width: 100%;
vertical-align: middle;
}
.one {
width: 25%;
}
.two {
width: 50%;
}
.four {
width: 50%;
height: 50%;
}
<section>
<div class="item one">
<img src="http://via.placeholder.com/400x400/">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/sss">
</div>
<div class="item two">
<img src="http://via.placeholder.com/400x200/000080">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/000080">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/">
</div>
<div class="item four">
<img src="http://via.placeholder.com/400x400/ff69b4">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/sss">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/sss">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/000080">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400/000080">
</div>
<div class="item one">
<img src="http://via.placeholder.com/400x400">
</div>
</section>