JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

CSS

.container {
  width: 100%;
  height: auto; /* CHANGED THIS */
  background: gray;
  padding-bottom: 1px; /* ADDED THIS */
}
.container div {
  width: 17.677%;
  padding-bottom: 17.677%;
  margin: 3.661%;
  transform: rotate(45deg);
  background: blue;
  float: left;
}

/* ADDED THIS */
.container div:last-child {
  float: none;
  display: inline-block;
  vertical-align: top;
}

JavaScript

// This JSFiddle is for the following StackOverflow answer:
// http://stackoverflow.com/a/36771593/5743988