Flexbox vs CSS Grid
People think flexbox and grid do the same job, and they do not. Flexbox lines things up in one row or one column. Grid puts things in rows and columns at once. Most pages use both: grid for the page, flexbox for the menu inside it.
Flexbox
A CSS layout that puts things in one row or column and shares the space.
Flexbox is a CSS layout that puts items in a row or a column. You turn it on with display: flex on the parent box. Then you choose how the items share the space. They can bunch at one end, spread evenly or sit in the middle. Items can grow or shrink to fit. It works along one direction at a time.
CSS Grid
A CSS layout that puts things in rows and columns at the same time.
CSS Grid is a layout that places items in rows and columns at once. You turn it on with display: grid and say how many columns you want. Each item then drops into the next cell. One item can span more than one cell, like a wide header. It works in two directions, which suits whole page layouts and galleries.
In one line
- Flexbox
- A CSS layout that puts things in one row or column and shares the space.
- CSS Grid
- A CSS layout that puts things in rows and columns at the same time.