Performance: RGBA and opacity manipulation
This affects the paint and composite stages of rendering, influencing how quickly colors and transparency are drawn on the screen.
$color: rgba(0, 0, 0, 0.5); .container { background-color: $color; }
$color: rgba(0, 0, 0, 0.5); .container { background-color: black; opacity: 0.5; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Opacity on container | None | 0 | High (repaints all children) | [X] Bad |
| RGBA background color | None | 0 | Low (paints only background) | [OK] Good |
rgba(255, 0, 0, 0.5) color value represent in Sass?.box { background-color: rgba(100, 150, 200, 0.4); opacity: 0.5; }.alert { background-color: rgba(255, 255, 0, 50%); }Pass the test and this pattern moves unknown