Masonry (Waterfall) Layout

Implementation Approaches — From Simple to Production-Ready

2⭐

Round-robin Columns

Even distribution across fixed columns. Simple but not true masonry; gaps appear due to height differences.

CSS JavaScript Basic
3⭐

CSS Multi-column

Pure CSS solution using column-count. Visual order is column-wise, not row-wise. Limited placement control.

CSS Only Multi-column Static
4⭐

CSS Grid + JavaScript

Modern CSS Grid with minimal JS to calculate row spans. Preserves source order with excellent responsive control.

CSS Grid JavaScript Modern
3⭐

Pure JavaScript

Zero dependencies with shortest-column algorithm. Fully controllable but requires more maintenance effort.

JavaScript Flexbox DIY
5⭐

Pinterest-style Absolute

Production approach using absolute positioning with calculated coordinates. Pixel-perfect control like Pinterest.

The actual approach Pinterest uses in production
Absolute Position JavaScript Production
4⭐

Colcade Library

Lightweight column-based layout helper by Desandro. Good middle-ground between simplicity and features.

Similar approach to Pure JS but packaged as a library
Library Lightweight Columns
5⭐

Masonry.js Library

The gold standard. Feature-rich, battle-tested library with animations, image loading, and dynamic content support.

Similar approach to Pinterest but with advanced features and optimizations
Library Feature-rich Industry Standard