Flexbox Wrapping: Free Web Development Tutorial
Master Responsive Navigation with CSS Flexbox Wrapping
This tutorial assumes you have basic knowledge of HTML and CSS. You'll need a code editor and Firefox browser for the DevTools exercises.
Core Flexbox Concepts You'll Master
Flex-Wrap Property
Learn how to allow flex items to wrap onto multiple lines when they don't fit in the container. Essential for responsive design.
Flex-Grow & Flex-Basis
Master sizing flex items to fill available space and set their initial size before free space is distributed.
Responsive Navigation
Build a navigation that adapts from single-line desktop layout to multi-line mobile grid using media queries.
Setup Your Development Environment
Open Project Files
Navigate to Desktop > Class Files > yourname-Flexbox Grid Class > Flexbox Wrapping folder and open it in your code editor
Launch Preview
Open index.html in Firefox browser to preview your work and access DevTools for responsive testing
Prepare Workflow
Keep both your code editor and Firefox open side-by-side for efficient development and testing
Dock DevTools to the right side of Firefox to simulate narrow screen widths more effectively. This allows you to test responsive behavior without making your entire browser window tiny.
Before vs After Adding Flex-Wrap
| Feature | Without Flex-Wrap | With Flex-Wrap |
|---|---|---|
| Overflow Behavior | Items stay on one line, causing horizontal scroll | Items wrap to new lines when space is limited |
| User Experience | Poor - requires horizontal scrolling | Good - content remains accessible |
| Responsive Design | Breaks on small screens | Adapts to screen size |
Progressive Enhancement Steps
Logo Full Width
Set flex-basis: 100% on logo for screens under 570px wide
Items Grow to Fill Space
Add flex-grow: 1 to navigation items to eliminate white space
Center Text Content
Apply text-align: center for better visual balance
Create Even Grid
Set flex-basis: 50% for consistent 2x2 grid layout
The flex shorthand property combines flex-grow, flex-shrink, and flex-basis into one declaration: flex: 1 0 50% means grow factor 1, shrink factor 0, and basis 50%.
margin-right: auto
Navigation Layout Breakpoints
Final Layout Verification
Navigation items should form an even grid below the full-width logo
All nav links should fit on one line below the logo at mid-range widths
Logo should be left-aligned with nav links pushed to the right side
Layout changes should be smooth when resizing the browser window
Key Takeaways

button at the top right of the DevTools panel and choose Dock to Right.