Modern web navigation bars, card lists, button groups, and modal layouts rely heavily on CSS Flexbox. Tailwind CSS transforms Flexbox into a concise, declarative toolkit that eliminates cumbersome flex container boilerplate.
To activate flex layout, apply the flex utility to a container:
| Class | CSS Equivalent | Description |
|---|---|---|
flex-row | flex-direction: row; | Default horizontal layout (left to right) |
flex-col | flex-direction: column; | Vertical layout (top to bottom) |
flex-row-reverse | flex-direction: row-reverse; | Reverse horizontal order |
flex-wrap | flex-wrap: wrap; | Allows items to wrap onto next line when full |
flex-nowrap | flex-wrap: nowrap; | Forces all items onto a single overflowing row |
justify) vs Cross-Axis (items) AlignmentgapNever use manual mr-4 on flex children; use the container gap utility:
flex-1, grow, and shrink-0gap-4 on a parent flex container preferred over applying mr-4 to each flex child?shrink-0 utility class do when applied to a flex child?flex-1 on a child element?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.