Performance: Flex container
MEDIUM IMPACT
Flex containers affect how the browser calculates layout and paints elements, impacting rendering speed and visual stability.
display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center; width: 100%; /* Use fixed flex-basis and avoid nested flex containers */
display: flex; flex-wrap: wrap; justify-content: center; align-items: center; width: 100%; /* Each item uses flex-grow: 1 with complex nested flex containers */
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Nested flex containers with many flex-grow items | High (many nodes recalculated) | Multiple reflows on resize | High paint cost due to layout changes | [X] Bad |
| Single-level flex container with fixed flex-basis | Low (few recalculations) | Single reflow on resize | Low paint cost | [OK] Good |