Performance: Mix blend modes
Mix blend modes affect the paint and composite stages of rendering, impacting how layers combine visually.
Jump into concepts and practice - no test required
<div class="relative"> <img src="image1.jpg" alt="Background" class="w-full"> <div aria-hidden="true" class="absolute top-0 left-0 w-full h-full bg-black bg-opacity-30 pointer-events-none"></div> </div>
<div class="relative"> <img src="image1.jpg" alt="Background" class="w-full"> <img src="image2.png" alt="Overlay" class="absolute top-0 left-0 mix-blend-multiply w-full"> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large overlay with mix-blend-multiply | Minimal | 0 | High (full overlapping area repaint) | [X] Bad |
| Semi-transparent overlay div | Minimal | 0 | Low (simple opacity paint) | [OK] Good |
mix-blend-multiply do to overlapping elements?mix-blend-multiply class multiplies the colors where elements overlap, resulting in a darker combined color.mix-blend- followed by the blend mode name, so for 'screen' it is mix-blend-screen.blend-screen, mix-screen-blend, and screen-mix-blend do not follow the correct Tailwind class naming convention.<div class="bg-red-500 w-40 h-40"></div> <div class="bg-blue-500 w-40 h-40 mix-blend-multiply absolute top-0 left-0"></div>
mix-blend-multiply.<div class="bg-green-400 w-32 h-32 mix-blend-overlay">Overlay</div>
mix-blend-screen to blend its yellow color with the image behind it.