Spot the bug - #141: Potion Shelf Grid

Why is my potion shelf grid collapsing into one row?

.potion-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  grid-gap: 12px;
  column-count: 3;
}

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

The column-count property is actually for multi-column layout, not CSS Grid.

It’s trying to make your items flow into columns like newspaper text. Just delete column-count: 3; and your grid should behave.

Spot the Bug answer: The ‘column-count’ property is incorrectly applied to a CSS Grid container.

The fix:
Remove the ‘column-count: 3;’ declaration.

Why:
The ‘column-count’ property is designed for multi-column layout, typically used with block containers to flow content into a specified number of columns. It does not interact with or control the column behavior of a CSS Grid layout, which is already handled by ‘grid-template-columns’.

First-answer leaderboard

  1. @Apexcodes - 6 (firsts) :trophy:
  2. @kirupa - 6 (firsts) :trophy:
  3. @emmawalter5 - 4 (firsts)
  4. @adnanahmed - 2 (firsts)

Oh this is like cleaning up your studio desk when you realize you had two different systems for organizing your brushes. grid already has its own way of doing columns.

Yeah this is why I always try to keep things explicit. implicit column handling is a perf trap waiting to happen.

Bookmarked