Performance: Breakpoints
Breakpoints affect how CSS adapts layout and styles at different screen sizes, impacting rendering speed and visual stability.
Jump into concepts and practice - no test required
@media (max-width: 1200px) { .container { width: 100%; } } @media (max-width: 900px) { .container { width: 90%; } } @media (max-width: 600px) { .container { width: 80%; } }
@media (max-width: 1200px) { .container { width: 100%; } } @media (max-width: 1199px) { .container { width: 90%; } } @media (max-width: 1198px) { .container { width: 80%; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Many close breakpoints | No extra DOM nodes | Multiple reflows on resize | High paint cost due to frequent changes | [X] Bad |
| Few well-spaced breakpoints | No extra DOM nodes | Single reflow per breakpoint change | Lower paint cost, smoother transitions | [OK] Good |
body have on a screen width of 700px?@media (max-width: 600px) { body { background: red; } } @media (min-width: 601px) { body { background: blue; } }@media screen and max-width: 800px { body { font-size: 1.2rem; } }