惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
Webroot Blog
Webroot Blog
GbyAI
GbyAI
S
SegmentFault 最新的问题
Cyberwarzone
Cyberwarzone
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 【当耐特】
S
Secure Thoughts
酷 壳 – CoolShell
酷 壳 – CoolShell
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
S
Security Affairs
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
Spread Privacy
Spread Privacy
T
Threatpost
Forbes - Security
Forbes - Security
C
Cisco Blogs
Scott Helme
Scott Helme
Attack and Defense Labs
Attack and Defense Labs
Simon Willison's Weblog
Simon Willison's Weblog
腾讯CDC
The Last Watchdog
The Last Watchdog
Cloudbric
Cloudbric
Last Week in AI
Last Week in AI
Recorded Future
Recorded Future
小众软件
小众软件
V
Vulnerabilities – Threatpost
美团技术团队
人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News - Newest:
Hacker News - Newest: "LLM"
I
Intezer
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 司徒正美
C
Cybersecurity and Infrastructure Security Agency CISA
Martin Fowler
Martin Fowler
博客园 - 聂微东

Adactio

June 16th, 2026, 11:12am June 16th, 2026, 10:16am Enhancing with CSS Grid Lanes How building an HTML-first site doubled our users overnight Speaking in Dublin June 13th, 2026, 9:09pm A tale of two browsers Sarah Canary by Karen Joy Fowler June 12th, 2026, 5:59pm June 12th, 2026, 12:24pm June 12th, 2026, 8:58am June 11th, 2026, 6:22pm June 11th, 2026, 6:20pm June 10th, 2026, 6:25pm June 10th, 2026, 10:14am June 9th, 2026, 8:50pm June 9th, 2026, 1:55pm June 8th, 2026, 7:45pm June 8th, 2026, 4:32pm Amsterdamming June 5th, 2026, 3:16pm June 4th, 2026, 8:21pm June 2nd, 2026, 8:37pm 25 years of The Session Happy Monday everyone, and let's talk about gender and ethnicity ratios at tech events. AI and the Rise of Mediocrity May 28th, 2026, 7:24pm Picture at an exhibition May 27th, 2026, 9:41pm May 27th, 2026, 1:52pm May 25th, 2026, 8:03pm Gaeltacht cois Tamaise 2026 May 25th, 2026, 3:07pm May 23rd, 2026, 8:06pm May 23rd, 2026, 8:31am May 22nd, 2026, 3:38pm May 22nd, 2026, 8:19am May 22nd, 2026, 7:22am May 21st, 2026, 8:19pm Brigid by Kim Curran May 20th, 2026, 7:12pm The value is in the difficulty - Annotated May 17th, 2026, 6:21pm May 15th, 2026, 4:19pm Tito as Gaeilge The closing talks at UX London 2026 Three things about data Native Apps Should Be Avoided Whenever Possible — No One's Happy WebKit Features for Safari 26.5 May 11th, 2026, 4:17pm I knew my writing students were using AI. Their confessions led to a powerful teaching moment | Micah Nathan Gideon The Ninth by Tamsyn Muir May 8th, 2026, 3:55pm Better Browser Caching with No-Vary-Search May 7th, 2026, 9:55am May 7th, 2026, 7:49am The schedule for UX London 2026 Google’s Prompt API Reminder: You Can Stitch Together Lots of Little HTML Pages With Navigations For Interactions Netizen | Derek Sivers April 30th, 2026, 7:59pm April 29th, 2026, 8:12pm April 27th, 2026, 7:47pm April 25th, 2026, 12:03pm April 25th, 2026, 12:00pm April 25th, 2026, 8:03am April 24th, 2026, 7:57pm April 24th, 2026, 5:12pm Two Paradigms for Enhancing HTML Tags Summary punishment It's Not AI. It's FOMOnetization. Alistair Davidson / validation-enhancer · GitLab Never Lose Form Progress Again :: Aaron Gustafson Dilation Expansion artifacts April 19th, 2026, 6:03pm Finn Mac Cool by Morgan Llywelyn April 17th, 2026, 7:58am April 16th, 2026, 6:42pm Threat models No-stack web development Design and Engineering, As One · Matthias Ott April 14th, 2026, 7:21am April 13th, 2026, 7:47pm April 11th, 2026, 8:39am April 10th, 2026, 5:36pm My salary history Conference organising in 2026 April 7th, 2026, 8:32pm TinyStart AI Might Be Our Best Shot At Taking Back The Open Web | Techdirt April 6th, 2026, 12:46pm The AI Great Leap Forward April 4th, 2026, 6:42pm April 3rd, 2026, 5:27pm April 2nd, 2026, 8:58pm April 2nd, 2026, 4:32pm Web Day Out - 12 March 2026 Mistrust HTML Video Poster Image: Enable Responsive Images and ALT Text for Poster
The Field Guide to CSS Grid Lanes
2026-06-12 · via Adactio

Masonry layouts in pure CSS. No JavaScript. No hacks. Just four lines of code.

Brought to you by the team behind WebKit and Safari.

This is an interactive demo of CSS Grid Lanes. Try it in a browser with support.

Or simply scroll down to learn more about Grid Lanes.

(It is easy to use Grid Lanes today with simple fallbacks. This example skips them for clarity.)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

Resize width:

Field Guide

Grid Lanes Basics

display: grid-lanes

Apply display: grid-lanes to a layout container. Then define columns or rows. The children pack into grid lanes automatically.

.container {
  display: grid-lanes;
  grid-template-columns: 1fr 1fr 1fr;
}

grid-template-columns

Waterfall

Defining columns creates a vertical waterfall. Tab order flows back and forth across the page. Each item is placed wherever puts it closest to the top. Additional items can be lazy-loaded at the bottom.

grid-template-rows

Brick

Defining rows creates a horizontal brick layout. Tab order flows up and down. Each item is placed wherever puts it closest to the inline start edge.

Options for Lane Definitions

fr unit

One fractional unit. Divides available space proportionally. 1fr 2fr 1fr gives the middle track twice the width.

grid-template-columns: 1fr 2fr 1fr;

Fixed lengths

Use any CSS unit to define a fixed size. The classics: px, em, rem. Newer ones: ch (a character’s width), lh (a line’s height). Plus powerful viewport and container units. Pick the unit that fits the job.

grid-template-columns: 12ch 1fr 20rem;

Percentage

The % unit resolves to percentage of the container’s size. It works — but fr units are usually a better fit, since they account for gap and % doesn’t. Plus you won’t have to worry about adding up to 100%.

grid-template-columns: 25% 75%;

auto

Sized by content. Stretches to fill remaining space when there’s room.

grid-template-columns: auto 1fr;

min-content & max-content

min-content

Most Narrow

max-content

Widest it can possibly be, no wrap

min-content makes a box the smallest it can be without overflow. max-content makes a box the biggest it can be, sized to its content.

grid-template-columns: max-content 1fr;
grid-template-columns: min-content 1fr;

fit-content()

Shrink-wrap with a ceiling. When there’s less content, fit-content behaves just like max-content. When there’s more content, it doesn’t grow beyond the declared size.

grid-template-columns: fit-content(300px) 1fr;

minmax()

A flexible track sized between the declared minimum and maximum size. Using minmax(200px, 1fr) creates a track that’s never smaller than 200px, and grows to share any remaining space. When there’s more space, the browser automatically adds more tracks. Less space? Fewer tracks. No media or container queries needed!

grid-template-columns: minmax(200px, 1fr);

repeat()

Shorthand to repeat track patterns. These two lines are identical:

grid-template-columns: repeat(3, 1fr);
grid-template-columns: 1fr 1fr 1fr;

auto-fill vs auto-fit

auto-fill

auto-fit

Both automatically choose the number of tracks. auto-fill creates all tracks that will fit, even if empty. auto-fit creates tracks, but not more than there are items, so there are no empty tracks.

The Go-To

Want flexible equal-width columns, where additional columns appear and disappear automatically as space allows? Use this, adjusting the 120px length to your needs:

grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));

Or use this to ensure that when the space available is extra narrow (less than 120px), the single column does not overflow:

grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));

Options for Placement & Spacing

flow-tolerance

flow-tolerance: 0

1

2

3

4

flow-tolerance: 4lh

1

2

3

4

Grid Lanes packs each item into whichever lane has the most empty space. When lanes are nearly equal and a one-pixel difference matters, the visual order gets scrambled for no good reason. Use flow-tolerance to declare “how close” matters. Anything less is considered a tie, and content flows in writing mode order. This better syncs visual order with tab order. The best value depends on your content’s sizes — experiment and see. Default is 1em.

flow-tolerance: 4lh;

gap

One value for uniform spacing. Two values for different row-gap and column-gap. Works just like CSS Grid.

gap: 1rem 2rem;

Spanning Lanes

Stretch an item across multiple tracks. Great for featured content.

.featured {
  grid-column: span 2;
}
.featured {
  /* grid-column: span 2; */
}

Explicit Placement

Pin an item to a specific track.

.item-1 {
  grid-column: 3;
}
.item-1 {
  /* grid-column: 3; */
}

Good to Know

Source Order Preserved

Grid Lanes reorders items visually for tighter packing, but the DOM order stays intact. Keyboard navigation, screen readers, and find-on-page all follow the original source order.

Spanning and explicit placement can pull items further from their source position. The visual reading order may diverge from the tab order — so author your HTML in the sequence you want users to encounter it.

Progressive Enhancement

Use @supports to layer Grid Lanes on top of a simpler fallback. Browsers that don't support it still get a reasonable layout.

@supports not (display: grid-lanes) {
  ul { 
    columns: 3; 
  }
}
@supports (display: grid-lanes) {
  ul {
    display: grid-lanes;
    grid-template-columns: repeat(3, 1fr);
  }
}

Switching between waterfall and brick

To switch between Waterfall and Brick layout direction, be sure to unset the original track definition. There are many ways to do so. Here’s one:

.container {
  display: grid-lanes;
  grid-template-columns: 1fr 1fr 1fr;
}
@media (width < 500px) {
  .container {
    grid-template-columns: unset;
    grid-template-rows: 1fr 1fr 1fr;
  }
}

Explore Demos

View these demos in Safari 26.4 or later, or another browser that supports Grid Lanes.

Watch the Talk

Safari Web Inspector showing a Grid Lanes photo gallery, with a play button overlay and the WWDC26 logo.

Dive Deeper

Safari’s Grid Inspector shows you exactly how items flow across lanes — open the demos and try it yourself.

Safari’s Grid Inspector showing order numbers and lane boundaries on a Grid Lanes layout

From the Team

Ever since CSS Grid shipped in 2017, developers asked “How can I make a Masonry layout?” For years, the only option was to use JavaScript — often heavy, fragile, and not quite right. Now, CSS Grid Lanes solves this need, natively in the browser.

Grid Lanes went through years of design, prototyping, and debate within the CSS Working Group. The result is something we’re genuinely proud of. Four lines of CSS. No library. No framework. It’s fast and robust.

This website was made by the same people who’ve been involved from the beginning. Every demo, every diagram, every claim has been thoroughly reviewed for accuracy. This is exactly how Grid Lanes works, straight from the source.

We hope you create amazing things with Grid Lanes. It does far more than the classic masonry-style layout. We can’t wait to see what you make with it.