Top
Best
New

Posted by frizlab 3 days ago

CSS Grid Lanes(webkit.org)
744 points | 226 commentspage 2
interstice 3 days ago|
Kinda odd they didn't call it masonry given it's already been called that forever. At least grid-lanes is reasonably self explanatory.
pbowyer 3 days ago||
I'm pleased they rename it because grid-lanes opens up more than masonry layouts.

I've been waiting to be able to have a fully responsive layout (where interleave sidebar content in with the page content on small screens, but have it in a sidebar on larger screens) without using any JavaScript, and this finally makes it possible.

Demo: https://codepen.io/pbowyer/pen/raLBVaV

Previous comment: https://news.ycombinator.com/item?id=46228993

qingcharles 3 days ago||
The naming was half the discussion on implementing this. There were a lot of people smarter and more knowledgeable than me that had a lot of opinions on the name that I hadn't thought about. I remember one of the reasons was that the word "masonry" wasn't as obvious a concept for non-English speakers.
memonkey 3 days ago||
Masonry grid layout was one of a few interviewing pair programming tests I would give to frontend engineers. I need to see how this works under the hood!
ricksunny 3 days ago||
I wonder how long it takes LLMs to correctly ingest fresh CSS notation like this.
jeroenhd 3 days ago||
I have to ask, like with all the other browser specific trial implementations: how is cross platform support? If we wanted to make a grid layout that only worked in one browser engine, grid-template-rows: masonry was there for a while now.

Chromium still seems to be working on support it seems based on https://cr-status.appspot.com/feature/5149560434589696 so maybe it'll be useful soon? That page indicates that they're still discussing certain parts of the spec.

qingcharles 3 days ago|
It's been on-and-off in all three browsers behind flags etc, but it's been in a constant state of flux over the last three years. One of the most gnarly new CSS features to get right. Lots of great arguments about how to implement it.
oefrha 3 days ago||
I've been using Chromium's display: masonry in some internal apps since they introduced it behind a flag in Chromium 140. Looks like they just have to rename it now?
qingcharles 3 days ago|
I have too. And the Safari version that was in the betas/tech previews.

One of the biggest arguments over the last couple of years was what to call it. A lot, lot of ideas put forth as alternatives to "masonry" which wasn't thought to be great for non-English speakers. I'm glad they finally nailed a name for it!

The other big argument was over how to activate it. Is it a grid? Is it a flexbox? Is it a brand new animal?

Now I just need to figure out the best way to implement this semantically with a polyfill for the next 30 months until it's baseline.

oefrha 3 days ago||
I actually started using Safari's `grid-template-rows: masonry` when it came out, but unfortunately Safari TP crashed a lot on me when using that for some reason. Chromium's never had a problem.
imbnwa 3 days ago||
What’s the best resource for getting a handle on all modern CSS for someone who hasn’t paid attention since flex box
satvikpendem 3 days ago||
I like Josh W Comeau's content, he has a lot of free articles, but his paid CSS course goes through step by step why CSS is the way that it is, worked great for me for understanding it all. My work paid for it though, that's why it's priced so high, but I'm sure he has discounts for individuals.
alwillis 3 days ago|||
This should be a good start: https://nerdy.dev/cascading-secret-sauce
perardi 3 days ago||
There are a lot of resources.

I am a fan of: https://www.youtube.com/@KevinPowell

Kevin is a no-nonsense no-hype educator. He will keep you up to date without a lot of engagement hacking.

swyx 3 days ago||
how does it work with animations? like if i transition:all and then remove a middle img does the other elements get animated?
qingcharles 3 days ago|
I guess wire up a codepen demo and try it out. I know the guys writing this were well aware of all the edge cases like that and these are some of the absolute smartest CSS people you can think of who had to write the very detailed spec for this.

I don't think the smooth reflow made it into the current spec, so I guess watch this space?

https://www.w3.org/TR/css-grid-3/

nitwit005 3 days ago||
How would you query the location where you need to load more data when scrolling down (the highest empty spot)?
tom1337 3 days ago||
I guess you can just start loading a first batch, add an intersection observer to the last 3 elements (if you have 3 lanes) and then when one of those intersects you simply start fetching the next.
notpushkin 3 days ago||
Hmm, I think we only need to observe the `elements.at(-numberOfLanes)`, as it should be the first to enter the screen anyway.
rokkamokka 3 days ago|||
I suppose just checking scroll height of the container? Once you're x pixels above the bottom, fetch more. Not the smoothest, but doable
jonah 3 days ago||
You just append new <figure> elements to the <main> in the example and it will automatically put them in the appropriate column.
nitwit005 3 days ago||
Your answer doesn't appear to relate to what I asked. You need to know when to query the backend for more data if it's an infinite scrolling setup.
jonah 3 days ago||
Aahh. The way you phrased your question was pretty ambiguous.

The other posters have good answers. One thing to consider for a smooth interaction would be to eagerly load the next x elements before they scroll into view.

pcl 3 days ago||
Yeah I’d assume you’d eagerly load enough to make sure everything gets at least partially into the viewport, and maybe a fee more to optimize for network latency. And then perhaps track elements whose trailing ends are not in the viewport, and load more once those become fully visible?
temporallobe 3 days ago||
It’s always nice to see native implementations of functionality pioneered by third-party libraries. Bootstrap, for example, has made this kind layout (somewhat) possible but there is also a Masonry plugin that simplifies it.
todotask2 3 days ago|
I think Apple should make Safari stable downloadable option for all platforms.
speedgoose 3 days ago||
I’m old enough to have installed Safari on Windows XP. I’m not sure it has been enough years since this Apple failed product.
kuekacang 3 days ago||
experiencing how text renders differently, slowly, with my potato battleship
alwillis 3 days ago|||
There are WebKit-based browsers for Linux: https://webkit.org/downloads/
jacobp100 3 days ago||
This might actually happen indirectly. Kagi’s new browser uses WebKit. macOS only now, but eventually it’ll come to windows
todotask2 2 days ago||
I have been using Kagi Orion on macOS and iPhone, so far so good.
More comments...