CSS Grid: dynamically span the last column

Viewed 4897

Is it possible to automatically span the last column to occupy the remaining space in the grid? Basically I'm trying to achieve this:

enter image description here

.row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.col {
  background: blue;
  padding: 20px;
  border: 1px solid red;
}

.col:last-child {
  background: yellow;
  /* missing magic here */ 
}
<div class="row">
  <div class="col"></div>
  <div class="col"></div>
  <div class="col"></div>
</div>
<div class="row">
  <div class="col"></div>
  <div class="col"></div>
</div>
<div class="row">
  <div class="col"></div>
</div>

1 Answers
Related