<div class="container">
  <div class="grid">
    <div class="cell">
      <div class="inside big"></div>
    </div>
    <div class="cell">
      <div class="inside big"></div>
    </div>
    <div class="cell">
      <div class="inside medium"></div>
    </div>
    <div class="cell">
      <div class="inside big"></div>
    </div>
    <div class="cell">
      <div class="inside small"></div>
    </div>
    <div class="cell">
      <div class="inside medium"></div>
    </div>
    <div class="cell">
      <div class="inside small"></div>
    </div>
    <div class="cell">
      <div class="inside big"></div>
    </div>
    <div class="cell">
      <div class="inside medium"></div>
    </div>
    <div class="cell">
      <div class="inside small"></div>
    </div>
    <div class="cell">
      <div class="inside big"></div>
    </div>
  </div>
</div>
@gutter-size: 20px;

.container {
  border: 1px solid red;
  overflow: hidden;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  margin: -(@gutter-size / 2);
}

.cell {
  padding: (@gutter-size / 2);
  box-sizing: border-box;
  width: 25%;
  background: lightgray;
  z-index: -1;
}

.inside {
  background: blue;
}

.big {
  height: 200px;
}

.medium {
  height: 100px;
}

.small {
  height: 50px;
}

img {
  display: block;
}

@media (max-width: 1000px) {
  .grid {
    flex-direction: column;
  }
  
  .cell {
    width: 100%;
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.