Webflow sync, pageviews & more.
NEW

How can I build a real masonry layout (Pinterest layout) using Webflow and pure CSS without falling for the ineffective CSS columns hacks?

TL;DR
  • Use CSS Grid with explicit columns and set grid-auto-flow: dense to tightly pack items.
  • Allow child elements to have variable heights and use grid gaps for spacing, avoiding fixed heights and nested layouts.
  • Apply grid-auto-flow: dense via custom CSS in Webflow since it's not available in the visual UI.

To build a true masonry (Pinterest-style) layout in Webflow using pure CSS, avoid CSS columns and instead use CSS Grid with grid-auto-flow: dense, which allows explicitly placed, gapless layouts across grid rows and columns.

1. Use CSS Grid Instead of CSS Columns

  • CSS Columns often break accessibility and ordering, and don't allow reliable control over row and column gaps.
  • Webflow now supports advanced Grid properties, which makes it possible to build a true masonry layout with CSS Grid.

2. Set Up the Parent Grid Container

  • Select or create your grid container (e.g., a Div Block).
  • Go to the Style panel and:
  • Set Display: Grid.
  • Set grid-template-columns with a fixed or responsive number of columns. For example, 3 or use repeat(auto-fit, minmax(250px, 1fr)).
  • Set Grid Auto Flow: Row dense for tight packing of elements.

3. Allow Variable Heights

  • Masonry requires that child items have inherent or natural content height differences.
  • Each item in the grid should be allowed to grow vertically based on its content.
  • Don’t manually set a fixed height on the grid items.

4. Assign Sizing & Margins

  • Do not add top/bottom margins between items, as grid handles this. Instead:
  • Use row and column gaps within the grid settings for spacing.
  • Make sure the children are consistent in width but variable in height.

5. Avoid Nesting Grids or Flex Inside Items

  • Keep the layout clean and flat, as nested layout methods (like Flex inside Grid) can interfere with the “masonry” stacking effect.

6. Apply to Webflow via Custom CSS (if needed)

  • Webflow doesn’t yet expose grid-auto-flow: dense in the visual UI.
  • To achieve a dense masonry layout, add a custom <style> block in the page’s Before tag:
  • Example inline: use an embedded Style Embed component and target your grid class (e.g., .masonry).
  • Inside: .masonry { grid-auto-flow: dense; }.

7. Optional: Responsive Adjustments

  • Use media queries or Webflow’s breakpoints to adjust the number of columns (grid-template-columns) at different screen sizes for responsiveness.

Summary

To create a real masonry layout in Webflow with pure CSS, use CSS Grid with grid-auto-flow: dense, not CSS columns. Set up your container with explicit columns, let child items vary in height, and apply custom CSS to enable dense packing. This achieves a true Pinterest-style layout while preserving accessibility and layout stability.

Rate this answer

Other Webflow Questions