Lab 02: Flexbox Deep Dive
Overview
Step 1: The Flex Shorthand
/* Common patterns */
flex: 1; /* flex: 1 1 0% — grow, shrink, start from 0 */
flex: auto; /* flex: 1 1 auto — grow, shrink, use content size */
flex: none; /* flex: 0 0 auto — fixed, no grow/shrink */
flex: 0; /* flex: 0 1 0% — don't grow, can shrink */
/* Full explicit form */
.item {
flex-grow: 1; /* proportion of available space to take */
flex-shrink: 0; /* don't shrink below flex-basis */
flex-basis: 200px; /* ideal size before flex adjustment */
}
/* Common layouts */
.sidebar { flex: 0 0 280px; } /* fixed width sidebar */
.main { flex: 1; } /* main takes remaining space */
.icon { flex: 0 0 1.5rem; } /* icon won't flex */Step 2: Alignment — Two Axes
Step 3: Order & Flex-Wrap
Step 4: Auto Margin Tricks
Step 5: Holy Grail Layout
Step 6: Sticky Footer
Step 7: Responsive Card Grid
Step 8: Capstone — Validate with html-validate
Summary
Property
Values
Purpose
Last updated
