CSS - background-blend-mode
The background-blend-mode
CSS property describes how the element's background images should blend with each other and the element's background color.
Example
HTML
Copy Code
<div id="div"></div> <select id="select"> <option>normal</option> <option>multiply</option> <option selected>screen</option> <option>overlay</option> <option>darken</option> <option>lighten</option> <option>color-dodge</option> <option>color-burn</option> <option>hard-light</option> <option>soft-light</option> <option>difference</option> <option>exclusion</option> <option>hue</option> <option>saturation</option> <option>color</option> <option>luminosity</option> </select>
CSS
Copy Code
#div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'),url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: screen; }
JavaScript
Copy Code
document.getElementById("select").onchange = function(event) { document.getElementById("div").style.backgroundBlendMode = document.getElementById("select").selectedOptions[0].innerHTML; } console.log(document.getElementById('div'));
Syntax
CSS
Copy Code
/* One value */ background-blend-mode: normal; /* Two values, one per background */ background-blend-mode: darken, luminosity; /* Global values */ background-blend-mode: initial; background-blend-mode: inherit; background-blend-mode: unset;
Values
<blend-mode>
- Is a
<blend-mode>
denoting the blending mode to be applied. There can be several values, separated by commas.
Formal syntax
CSS
Copy Code
<a href="css/blend-mode" title="Possible values: normal, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color, luminosity"><blend-mode></a><a href="css/value_definition_syntax#hash_mark_(.23)" title="Hash mark">#</a>
Description
The background-blend-mode
CSS property describes how the element's background images should blend with each other and the element's background color.
Blending modes should be defined in the same order as the background-image
CSS property. If the blending modes' and background images' list lengths are not equal, it will be repeated and/or truncated until lengths match.
Initial value | normal |
---|---|
Applies to | All elements. In SVG, it applies to container elements, graphics elements, and graphics referencing elements.. It also applies to ::first-letter and ::first-line . |
Inherited | no |
Media | none |
Computed value | as specified |
Animatable | no |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Browser Compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 35 | 30.0 (30.0) | Not supported | 22 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | Not supported | 30.0 (30.0) | Not supported | 22 | 8 |
See Also
Specifications
Specification | Status | Comment |
---|---|---|
Compositing and blending Level 1 The definition of 'background-blend-mode' in that specification. |
Candidate Recommendation | Initial definition |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/background-blend-mode