Skip to content

Home

3-tile layout

Aligns items horizontally using display: inline-block to create a 3-tile layout.

ℹ Important

If you use relative units (e.g. em), using font-size: 0 to fight whitespace between blocks might cause side effects.

<div class="tiles">
  <div class="tile">
    <img src="https://via.placeholder.com/200x150">
    <h2>30 Seconds of CSS</h2>
  </div>
  <div class="tile">
    <img src="https://via.placeholder.com/200x150">
    <h2>30 Seconds of CSS</h2>
  </div>
  <div class="tile">
    <img src="https://via.placeholder.com/200x150">
    <h2>30 Seconds of CSS</h2>
  </div>
</div>
.tiles {
  width: 600px;
  font-size: 0;
  margin: 0 auto;
}

.tile {
  width: calc(600px / 3);
  display: inline-block;
}

.tile h2 {
  font-size: 20px;
}

More like this

Start typing a keyphrase to see matching snippets.