How the Masonry Grid Works

Journal10 April 2025
Illustrated boots marching in formation
Save Our Boots

The homepage and section list pages use a masonry grid — a layout where items of varying heights pack together without gaps, like a stone wall.

The Hybrid Approach

Pure CSS Grid gives us responsive columns but leaves vertical gaps. Pure JavaScript positioning is fragile on resize. The First Folio theme uses both:

  1. CSS Grid handles the horizontal layout — responsive columns that reflow based on viewport width.
  2. JavaScript runs after images load and adjusts vertical positioning to fill gaps.

This means the layout works (albeit with gaps) even when JavaScript is disabled.

Responsive Breakpoints

Breakpoints use em units rather than pixels, so the layout adapts when users change their browser’s default font size:

ViewportColumns
≤ 30em2
30–48em2
48–64em3
64–80em4
≥ 80em5
Alert
Using em-based breakpoints is a WCAG 2.1 requirement (Success Criterion 1.4.4). Pixel-based breakpoints break when users zoom.