Hacker News new | ask | show | jobs
by meerita 1490 days ago
Flex is becoming more and more irrelevant to do layouts. CSS Grid is really solid and it works well on responsive. The possibilities are endless.
4 comments

Flex and grid are 2 different domains.

Grid is good for making grids.

Flex is good for creating flows of content, like a <div> where all childs has display:inline-block. It supports wrapping when content can't be on a single line.

Exactly. But we came from using Flex as the defacto system to do layouts and more, now with CSS-Grid it does make sense to use flex for what it was meant for.
I guess it depends on your past experience, but for most of the teams I've been involved in, it was basically a leap from floats to grids for page layout, with flexbox being a small scale option before and after.
Anyone that had to support IE11 probably avoided grid for a long time but could still use flex.
Yes. The more older the project is usually goes with the avoidance of CSS-grid and other features.
Flex is way simpler to use and reason about, it's sufficient for a majority of cases and it works on IE11, which is still supported until 2025.

Grid is more powerful, but not by a huge margin and not in every case. You can get very far with just flex, calc, media queries, and some inline variables and some other tricks. Also grid needs a more global view so to speak and up-front design as opposed to the component based thinking that has become so prevalent.

I'm a fan of the feature but I don't think flex is becoming irrelevant anytime soon.

For page layout sure, but for stuff like a unknown-length sequence of blocks/tiles/cards of mixed size flexbox is getting more useful, especially now grid-gap is just gap and works on flexbox too.
Yes, it is useful for inline positioning, ex. a menu, but for the rest of the things mostly css does solve it without having to do much.
I think the next challenge would be to have a native "masonry" grid feature. That would cover several usecases.