Flexbox vs. CSS Grid — Which is Better?
Channel:Layout Land · Length:4:18 · Published:2018-01-30 · Views:314126
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
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
- The Thirty Million Line Problem · Molly Rocket · 1:48:55
- Lake Peigneur Drilling Accident · ankerssm · 8:23
- What the heck is the event loop anyway? | Philip Roberts | JSConf EU · JSConf · 26:52
- Rich Harris - Rethinking reactivity · You Gotta Love Frontend · 36:45
- Crockford on JavaScript - Volume 1: The Early Years · YUI Library · 1:42:08
- RailsConf 2016 - Turbolinks 5: I Can’t Believe It’s Not Native! by Sam Stephenson · Confreaks · 37:37
- JavaScript: The Good Parts · Google TechTalks · 1:03:47
- Pete Hunt: React: Rethinking best practices -- JSConf EU · JSConf · 29:31
- Dan Abramov - Live React: Hot Reloading with Time Travel at react-europe 2015 · ReactEurope · 30:40
- Hey Underscore, You're Doing It Wrong! · InfoQ · 36:30
- Chris McCord - Keynote: Phoenix LiveView - Interactive Apps without Javascript - ElixirConf EU 2019 · Code Sync · 1:12:41
- OAuth 2.0 and OpenID Connect (in plain English) · OktaDev · 1:02:17
- Jake Archibald on the web browser event loop, setTimeout, micro tasks, requestAnimationFrame, ... · JSConf · 35:12
- RiftSketch: Live coding in VR with the Oculus Rift, Firefox WebVR, JavaScript and Three.js · Brian Peiris · 10:36
- Interactive programming Flappy Bird in ClojureScript · Bruce Hauman · 6:22
- Build a real-time Twitter clone in 15 minutes with LiveView and Phoenix 1.5 · Chris McCord · 17:55