StealThis .dev

Masonry Grid

Pinterest-style masonry layout using CSS columns — items fill vertically with no gaps, responsive breakpoints.

Open in Lab
css
Targets: HTML

Code

Masonry Grid

A Pinterest-style masonry layout built entirely with CSS columns. Items of varying heights fill columns top-to-bottom with no empty gaps.

How it works

column-count and column-gap create the multi-column flow. Each card uses break-inside: avoid to prevent columns from splitting a card. This is the simplest zero-JS approach to masonry.

Responsive breakpoints

ScreenColumns
< 480px1
480–768px2
768–1024px3
1024px+4

Limitations

CSS columns fill top-to-bottom (column-first), not left-to-right (row-first). For row-first ordering, a JavaScript-based approach (e.g., Masonry.js) is needed.

Features

  • Zero JavaScript
  • Responsive column count via media queries
  • Hover lift effect with subtle shadow
  • break-inside: avoid prevents card splits