Display Flex and Flex Direction
Enable flexbox on a container and control the main axis direction with flex-direction.
Enabling Flexbox
Flexbox is activated by setting display: flex on a container element (the flex container). Its direct children automatically become flex items.
.nav {
display: flex;
}
/* All direct children of .nav are now flex items */Inline Flex
display: inline-flex creates a flex container that flows inline (like inline-block) instead of as a block. The internal flexbox behavior is identical.
.badge {
display: inline-flex;
align-items: center;
gap: 4px;
}All lessons in this course
- Display Flex and Flex Direction
- Justify-Content and Align-Items
- Flex Wrap and Align-Content
- Flex Grow Shrink and Basis