mix-blend-mode
Definition
The mix-blend-mode property sets how the content of an element should blend with its background or with the content of the element behind it. It is used to create effects like screen overlays, color burn, or multiply.
Examples
Using mix-blend-mode to create a screen overlay effect:
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
mix-blend-mode: screen;
}
Using mix-blend-mode to create a color burn effect:
.color-burn {
background-color: #f00;
mix-blend-mode: color-burn;
}
Using mix-blend-mode to create a multiply effect:
.multiply {
background-color: #00f;
mix-blend-mode: multiply;
}
Values
Value | Description |
---|---|
normal | Default value. The element's content is drawn on top of the background. |
multiply | The element's content is multiplied with the background. |
screen | The element's content is screened onto the background. |
overlay | The element's content is overlaid onto the background. |
darken | The darker of the element's content and the background is displayed. |
lighten | The lighter of the element's content and the background is displayed. |
color-dodge | The element's content is color-dodged with the background. |
color-burn | The element's content is color-burned with the background. |
hard-light | The element's content is applied to the background as if it were a hard light. |
soft-light | The element's content is applied to the background as if it were a soft light. |
difference | The difference between the element's content and the background is displayed. |
exclusion | The exclusion of the element's content and the background is displayed. |
hue | The hue of the element's content is applied to the background. |
saturation | The saturation of the element's content is applied to the background. |
color | The color of the element's content is applied to the background. |
luminosity | The luminosity of the element's content is applied to the background. |
<custom-ident> | A custom blending mode defined using the @layer at-rule. |
Best Practices
- Use mix-blend-mode sparingly, as it can cause performance issues, especially on complex or animated elements.
- Choose the appropriate blending mode for your desired effect. Experiment with different blending modes to find the one that works best for your design.
- Be mindful of contrast and legibility when using mix-blend-mode. Some blending modes can make text or other content difficult to read.
- Use mix-blend-mode in conjunction with other CSS properties, such as opacity, background-color, and border-radius, to create interesting and unique effects.
- Test your designs on different browsers and devices to ensure compatibility.
Browser Compatibility
Chrome | Firefox | Safari | Internet Explorer | Microsoft Edge | Opera |
---|---|---|---|---|---|
Yes | Yes | Yes | No | Yes | Yes |