Performance: Background position
Background position affects how the browser paints background images, impacting paint and composite stages.
Jump into concepts and practice - no test required
background-position: center center;background-position: calc(50% + 10px) calc(50% + 10px);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| background-position: calc(50% + 10px) calc(50% + 10px); | none | 0 but triggers style recalculation | high paint cost on resize | [X] Bad |
| background-position: center center; | none | 0 | low paint cost | [OK] Good |
background-position control in a webpage?background-position property sets the location of the background image inside an element.background-size control size, and background-color controls color, not position.top right is incorrect order.top left, which is vertical then horizontal, so it is incorrect. background-position: right top; uses right top, which is horizontal then vertical, the correct order.div { background-image: url('flower.png'); background-position: 50% 100%; } Where will the background image appear inside the div?section { background-position: 20px 30px 40px; }background-position: 10px 20%; is correct.