Performance: Position relative
MEDIUM IMPACT
Position relative affects layout stability and paint performance by creating a new positioning context without removing the element from the normal document flow.
div {
position: relative;
top: 10px;
left: 10px;
}div {
position: absolute;
top: 10px;
left: 10px;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| position: absolute with offset | Removes element from flow, affects siblings | Triggers reflow for siblings | High paint cost due to layout changes | [X] Bad |
| position: relative with offset | Element stays in flow, no sibling impact | No reflow triggered | Paint and composite only | [OK] Good |