All checks were successful
Build Hugo Site / build (push) Successful in 10s
809 B
809 B
title, date, categories, tags
| title | date | categories | tags | |||||
|---|---|---|---|---|---|---|---|---|
| CSS Grid vs Flexbox: When to Use What | 2024-08-03 |
|
|
CSS Grid vs Flexbox: When to Use What
Understanding the differences between CSS Grid and Flexbox for modern layouts.
Use Flexbox For:
- One-dimensional layouts (rows OR columns)
- Component-level design
- Centering content
- Navigation bars
Use CSS Grid For:
- Two-dimensional layouts (rows AND columns)
- Page-level design
- Complex layouts
- Card grids
/* Flexbox for navigation */
.nav {
display: flex;
justify-content: space-between;
align-items: center;
}
/* Grid for main layout */
.layout {
display: grid;
grid-template-columns: 1fr 3fr 1fr;
grid-template-rows: auto 1fr auto;
}
Both are powerful tools - use them together!