S
7

Couldn't figure out why my CSS grid kept breaking until I stumbled on this one line

Spent 3 hours last night fighting with a layout that refused to stack right on mobile. Turns out I just needed minmax(0, 1fr) instead of 1fr alone to stop the grid from overflowing. Anyone else run into this invisible wall nonsense?
2 comments

Log in to join the discussion

Log In
2 Comments
kelly_west74
Oh man, I gotta push back a little on this one... I've been using plain 1fr for years and it works fine most of the time. The overflow issue usually comes from something else in the grid setup, like not setting a min-width on columns or having content that just won't shrink down. minmax(0, 1fr) feels like a bandaid when the real problem is somewhere else in the CSS. I'd rather track down why things are overflowing instead of adding a workaround that might change how the grid behaves in other ways. It's a useful trick for sure, but I see people jump to it as a fix-all when it's really just changing the minimum column size to zero.
0
emery19
emery1915d ago
Wait, you're telling me you've never run into overflow issues with 1fr? That's genuinely surprising to me, @kelly_west74. I've had it happen plenty of times with fixed-width images and long words that just won't wrap, and minmax(0, 1fr) has been a lifesaver. I'd rather spend 5 seconds on the fix than hunt down every little overflow gremlin in the grid.
8