Intro to Flexbox: Free Web Development Tutorial
Master CSS Flexbox Layout and Alignment Fundamentals
What You'll Master in This Tutorial
Display Flex Properties
Learn how to transform static layouts into dynamic flex containers with display properties.
Axis Alignment Control
Master justify-content and align-items for precise positioning on main and cross axes.
Flexible Directions
Switch between row and column layouts while understanding how axes change behavior.
Firefox provides superior DevTools for inspecting flexbox layouts, making it easier to visualize how flex properties affect your elements in real-time.
Setup Your Development Environment
Launch Code Editor
Open Visual Studio Code, Sublime Text, or your preferred editor to access the project files.
Navigate to Project
Open the Flexbox Intro folder from Desktop > Class Files > yourname-Flexbox Grid Class.
Preview in Firefox
Open index.html in Firefox to see the initial layout with gray borders and colored elements for visual reference.
Flex vs Inline-Flex Behavior
| Feature | display: flex | display: inline-flex |
|---|---|---|
| Container Width | Full parent width | Content width only |
| Positioning | Block-level element | Inline-level element |
| Use Case | Main layout containers | Inline flex components |
When you set display: flex on an element, it becomes a flex container and its direct children automatically become flex items. This parent-child relationship is fundamental to flexbox behavior.
Row vs Column Direction Impact
| Feature | flex-direction: row | flex-direction: column |
|---|---|---|
| Main Axis | Horizontal | Vertical |
| Cross Axis | Vertical | Horizontal |
| justify-content Controls | Horizontal alignment | Vertical alignment |
| align-items Controls | Vertical alignment | Horizontal alignment |
Use 100vh instead of 100% for full viewport height. Viewport units (vh, vw) are relative to the visible portion of the page, making them more reliable for layout calculations.
Key Takeaways

