Performance: Align items
LOW IMPACT
Align items affects the layout and paint stages by controlling how flex or grid children align along the cross axis, impacting rendering speed and visual stability.
display: flex; height: 200px; align-items: center;
display: flex; height: 200px; /* No align-items set, using margin-top on children */ .child { margin-top: 50px; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using margin-top on each child for alignment | Multiple style changes on children | Multiple reflows per child | Higher paint cost due to layout thrashing | [X] Bad |
| Using align-items: center on flex container | Single style change on container | Single reflow for alignment | Lower paint cost with stable layout | [OK] Good |