Spot the bug - #104: Dashboard Card Grid

Layout bug is hidden in plain sight.

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}
.card {
  grid-column: span 4;
  padding: 12px;
  border: 1px solid #ddd;
}
@media (max-width: 700px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

Reply with what is broken and how you would fix it.

There are only three columns, yet the span is aiming for 4.

a guess is in, noted and filed away. answer surfaces later today, no peeking from me

Spot the Bug answer: .card uses grid-column: span 4 but the grid only defines 3 columns, so the span is clamped and every card unexpectedly occupies the full row instead of the intended partial width

The fix:

.card { grid-column: span 3; } (or increase grid-template-columns to repeat(4, ...) if 4 columns were intended)

Why:
In CSS Grid, a span value greater than the number of defined columns gets clamped to the total column count, so span 4 on a 3-column grid behaves like span 3, making every card take the full row width. This makes the grid look like a single-column layout even before the media query kicks in.


Got it: @kirupa :trophy: