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
  • Create a CMS Collection with image, link, and size category fields.
  • Add a Collection List, bind it to your CMS, and include an image/link block inside each item.
  • Set the Collection List Wrapper to CSS Grid with columns and gaps adjusted for responsiveness.
  • Assign combo classes (e.g., .grid-item.small/medium/large) and use conditional visibility or custom code to control layout per size.
  • Set object-fit: cover for images and use grid row/column span settings for dynamic layouts.
  • Adjust columns and spans on Tablet/Mobile for full responsiveness.

To create a dynamic, flexible grid layout in Webflow where images from a CMS Collection automatically populate and vary in size or positioning, use Webflow’s CMS in combination with CSS Grid or Flexbox and custom settings. Here's how:

1. Set Up a CMS Collection

  • Create a CMS Collection with fields like:
  • Image
  • Slug or Link
  • Size Category (e.g., small, medium, large — you’ll use this later for layout sizing)

2. Add a Collection List to Your Page

  • Drag a Collection List onto the canvas.
  • Connect it to your CMS Collection from Step 1.
  • Inside the list, add:
  • An Image element bound to the Image field.
  • A Link Block or Anchor Wrapper tied to the Slug or link field.

3. Use CSS Grid for the Parent Layout

  • Select the Collection List Wrapper, then:
  • Go to Display Settings and set it to Grid.
  • Define the number of columns (e.g. 4) and adjust row/column gaps as needed.
  • Use Auto or Min/Max sizing to let the grid flow responsively.

4. Allow Variable Image Sizing Using Conditional Sizes

  • On the Collection Item, enable custom sizing by adding a reference class such as .grid-item.
  • Then, for each size variant, add combo classes like:
  • .grid-item.large
  • .grid-item.medium
  • .grid-item.small
  • Use Conditional Visibility or Custom Code + CMS field values to apply different layout behavior per item.
  • In the Style Panel, adjust each combo class:
  • Example: Set .grid-item.large to span 2 columns and 2 rows using the Grid Row Span and Grid Column Span options.

5. Optimize Image Positioning and Overflow

  • Make sure images are set to cover or use object-fit: cover.
  • Set the height and aspect ratio either directly or using Webflow’s padding trick with % to maintain layout consistency.

6. Make It Responsive

  • On Tablet and Mobile, reduce the number of columns controlled in the Grid layout.
  • Modify or remove row/column spans as needed for better stacking behavior.

Summary

Use Webflow’s CSS Grid, CMS Collection Lists, and conditional span behavior to create a dynamic image grid. Vary image sizes with CMS fields and apply custom combo classes to span multiple rows/columns. This creates a fluid, Pinterest-style layout that updates automatically via your collection.

Rate this answer

Other Webflow Questions