Webflow sync, pageviews & more.
NEW

How can I create a dynamic grid layout in Webflow that automatically populates images and links from a collection, where some images are larger and others flow around each other nicely?

TL;DR
  • Set up a CMS Collection with image, link, and size type fields.
  • Add a Collection List to the page and bind image/link elements to CMS fields.
  • Style the Collection List as a CSS Grid with responsive columns and gaps.
  • Use CMS-driven conditional combo classes (e.g., .large, .medium) to define grid item spans.
  • Adjust grid column/row spans via class styles for varied item sizes.
  • Ensure responsive behavior using auto-fit or auto-fill and adapt layout per breakpoint.
  • For a masonry layout alternative, switch to CSS Columns instead of Grid.

To create a dynamic grid layout in Webflow with varying image sizes and responsive flow from CMS content, you need to use Collection Lists combined with CSS Grid and optional responsive tweaks.

1. Set Up Your Collection

  • Add a Collection (e.g., "Gallery" or "Projects") in the CMS.
  • Include fields like:
  • Image (for the thumbnail)
  • Link (optional – link to a project or URL)
  • Size Type (e.g., Small, Medium, Large – to define image span in the grid)

2. Add a Collection List to the Page

  • Drag a Collection List into your page.
  • Connect it to your relevant CMS Collection.
  • Inside the Collection Item, add your:
  • Image Element, connected to the Image field.
  • Link Block, if you want the image to click through to another page or URL.

3. Style the Collection List as a CSS Grid

  • Select the Collection List Wrapper and go to the Style panel.
  • Display: Grid
  • Set:
  • Grid Template Columns: Choose a layout (e.g., repeat(auto-fit, minmax(200px, 1fr)) implicitly for flexibility)
  • Gap: Add spacing between grid items

4. Define Image Sizing Using Conditional Classes

  • Use the CMS field you created (e.g., Size Type = Small/Medium/Large).
  • Assign Conditional Visibility or Combo Classes to Collection Items based on their size:
  • Create Combo Classes like .grid-item.large, .grid-item.medium, etc.
  • Inside the Collection List Item, apply these based on the CMS field.

5. Adjust Grid Row and Column Span with Custom Classes

  • For each Combo Class (.large, .medium), set:
  • Grid Column Span (e.g., Span 2 columns for .large)
  • Grid Row Span, if desired (using grid-row: span 2)
  • This allows larger images to take up more space in the grid.

6. Ensure Responsive Behavior

  • Adjust grid settings at different breakpoints to optimize layout.
  • Use auto-fit or auto-fill for fluid resizes, or adjust minmax() values in desktop vs. mobile.

7. Optional: Use Masonry-Like Layout with CSS Columns (Alternative Approach)

If irregular flow is more desired than strict grid:

  • Use Display: Block on Collection List.
  • Apply Columns styling instead of Grid (e.g., 3 columns on desktop, 1 on mobile).
  • This emulates a masonry layout, letting images stack vertically and wrap around.

Summary

To build a dynamic and responsive grid layout in Webflow using CMS images and links, use CSS Grid on the Collection List, assign column/row spans via combo classes, and map those to CMS data. For a looser, masonry-style layout, use CSS Columns instead.

Rate this answer

Other Webflow Questions