Flexbox vs. CSS Grid — Which is Better?

Channel:Layout Land · Length:4:18 · Published:2018-01-30 · Views:314126

Watch on YouTube

Summary

Jen Simmons explains the difference between CSS Flexbox and CSS Grid, and when to use each. She makes the case that Grid does not replace Flexbox and most sites use both.

Why HN recommends it

Recommended as a short, clear rundown of one-dimensional versus two-dimensional layout.

Here's a great explanation from Jen Simmons that really helped me understand the differences — HN, 2018

Web development

Subtitles (excerpt)

- One of the biggest questions people ask when they first learn about CSS Grid is, "Hey, does this replace Flexbox? "Should I use Grid instead of Flexbox?" No, that's not really how things are gonna work. So, Grid has been invented to do things that Flexbox couldn't do, and Flexbox is still a great tool for us to use to do things that Grid can't do. And we're also gonna use a lot of the other parts of CSS that we've used for layout for a long time. Floats, for example, there'll be plenty of times to use a float. And flow, the way the web pages get laid out, the way it's always been before CSS actually was invented, the way content flows down the page in a block direction or an in-line direction, these are all parts of a larger picture that we'll want to understand, and put Grid into that situation. We'll use Grid on certain parts of the page, and not on other parts of the page. It's not like the tools that we've been using, say, Bootstrap or Foundation, or 960 Grid, back in the day. It doesn't handle layout for the whole page. It handles layout for a particular container, one container on the page, and the items that are directly, a direct child of that container. So, you're gonna mix Grid with other things.

On Hacker News

Here's a great explanation from Jen Simmons that really helped me understand the differences and respective strengths and weaknesses of each: [VIDEO] — ljoshua, 2018-07
Grid is awesome, and I highly recommend learning what it can do for you. That said, they serve different purposes. However, between the two of them they address 97% of my needs on the frontend. This[1] is a good rundown of what the two do/dont do. [1] - [VIDEO] — JamesSwift, 2020-04
The two occupy a venn diagram of functionality. They do some stuff the same, but they also both do unique things the other doesnt. See this for a good rundown: [VIDEO] — JamesSwift, 2020-04
They serve different purposes, and you'll often want to use both for different pieces of the layout. Flexbox is for laying things out in one dimension, Grid is more for two-dimensional ones. This video might help show the difference (and all the Layout Land videos are great if you want to look more into CSS grid): [VIDEO] — Deimorz, 2018-05

Related videos