Lesson 19 of 55
HTMLFlexbox Layout
10 min
Course progress35%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 19 of 55
HTML10 min
Keep these ideas in mind as you work through the lesson.
.container {
display: flex;
flex-direction: row; /* row (default) or column */
justify-content: space-between; /* main‑axis alignment */
align-items: center; /* cross‑axis alignment */
flex-wrap: wrap; /* allow items to wrap */
gap: 1rem; /* spacing between items */
}
flex-direction – row (default) or column.justify-content – Aligns items on the main axis (flex-start, center, space-around, space-between).align-items – Aligns items on the cross axis (stretch, flex-start, center).flex shorthand (flex: 1 0 auto) controls growth, shrink, and basis.gap – Modern spacing property; replaces margin tricks.<nav class='nav'>
<a href='#'>Home</a>
<a href='#'>About</a>
<a href='#'>Contact</a>
</nav>
.nav { display: flex; gap: 1rem; }
order – Re‑order items for different breakpoints without changing HTML.flex-basis – Set the default size before growing/shrinking.align-self – Override the container’s align-items for a single child.display:flex applied to a container? ✅justify-content) and cross‑axis (align-items) set intentionally? ✅gap used instead of margins where possible? ✅order used for responsive re‑ordering? ✅Tip: Use the Flexbox Inspector in Chrome DevTools to visualise flex lines and item distribution.