
Sign up to save your podcasts
Or


Here are a few of my least favorite, easy to forget, unintuitive CSS layout "solutions":
Height 0? Wat? Shrink 0? Wat? Theo thinks he likes it. But…
Then there's minmax(min(), 1fr)? Wat?
Functional programming much?…
The minimum width of grid and flex children is auto. Setting it explicitly to 0 removes the intrinsic size, unlocking various things.
Study more about it on CSS Tricks by Chris Coyier or from Theo over on YouTube.
Often I'll make a flex layout where 1 child should be "pushy" or a dominant space consumer. Works great until a sibling to the pusher goes oval at small viewports, even though a firm height and width are set.
The fix:
So intuitive. Not.
So I don't have this full, triple nested function memorized. I can remember "repeat, auto-fit, minmax" as like the summary of the trick. Which gets me this far:
But that's not the full snippet I end up using in production. It works great until it's a single column of 10rem minimum width boxes. At which point, they dont go smaller, and so they can cause horizontal overflow in a parent container that's smaller than 10rem.
The fix:
It's extra to write, but it unlocks the "intrinsically responsive grid layout", which behaves as I was hoping all along.
Study more in this post from Evan Minto:
When the container is smaller than 10rem, the minimum value in our minmax() expression is set to the full width of the container, giving us a nice single-column view with no overflow. When the container is larger than 10rem, the minimum value is set to 10rem, so we get a responsive grid with equal tracks of at least 10rem each.
By Here are a few of my least favorite, easy to forget, unintuitive CSS layout "solutions":
Height 0? Wat? Shrink 0? Wat? Theo thinks he likes it. But…
Then there's minmax(min(), 1fr)? Wat?
Functional programming much?…
The minimum width of grid and flex children is auto. Setting it explicitly to 0 removes the intrinsic size, unlocking various things.
Study more about it on CSS Tricks by Chris Coyier or from Theo over on YouTube.
Often I'll make a flex layout where 1 child should be "pushy" or a dominant space consumer. Works great until a sibling to the pusher goes oval at small viewports, even though a firm height and width are set.
The fix:
So intuitive. Not.
So I don't have this full, triple nested function memorized. I can remember "repeat, auto-fit, minmax" as like the summary of the trick. Which gets me this far:
But that's not the full snippet I end up using in production. It works great until it's a single column of 10rem minimum width boxes. At which point, they dont go smaller, and so they can cause horizontal overflow in a parent container that's smaller than 10rem.
The fix:
It's extra to write, but it unlocks the "intrinsically responsive grid layout", which behaves as I was hoping all along.
Study more in this post from Evan Minto:
When the container is smaller than 10rem, the minimum value in our minmax() expression is set to the full width of the container, giving us a nice single-column view with no overflow. When the container is larger than 10rem, the minimum value is set to 10rem, so we get a responsive grid with equal tracks of at least 10rem each.