🌐Flexbox
Also known as CSS Flexbox, Flexible Box Layout, display: flex
A CSS layout that puts things in one row or column and shares the space.
Think of it like
Think of it like books on a shelf. You can push them left, spread them out or stand them in the middle.
Example
Lucy's menu has five links. With display: flex and gap: 1rem, they sit in a neat row with even gaps.
Why it matters
Menus, toolbars and cards are lined up this way on most sites. It also makes centring a box simple.
Definition
Example code
css
.menu {
display: flex;
justify-content: space-between;
}Common mistake
Key takeaways
- 1One direction. A row or a column, not both.
- 2Share the space. Items can grow, shrink or spread out.
- 3Set on the parent. display: flex goes on the box around them.