--- title: background-blend-mode slug: Web/CSS/background-blend-mode translation_of: Web/CSS/background-blend-mode ---
{{CSSRef()}}
background-blend-mode CSS属性定义该元素的背景图片,以及背景色如何混合。
混合模式应该按{{cssxref("background-image")}} CSS属性同样的顺序定义。如果混合模式数量与背景图像的数量不相等,它会被截取至相等的数量。
{{cssinfo}}
Formal syntax: {{csssyntax("background-blend-mode")}}
/* 单值 */ background-blend-mode: normal; /* 双值,每个背景一个值 */ background-blend-mode: darken, luminosity; background-blend-mode: initial; background-blend-mode: inherit; background-blend-mode: unset;
#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;
}
document.getElementById("select").onchange = function(event) {
document.getElementById("div").style.backgroundBlendMode = document.getElementById("select").selectedOptions[0].innerHTML;
}
console.log(document.getElementById('div'));
{{ EmbedLiveSample('Examples', "330", "330") }}
| 规范 | 状态 | 备注 |
|---|---|---|
| {{ SpecName('Compositing', '#background-blend-mode', 'background-blend-mode') }} | {{ Spec2('Compositing') }} | 首次定义 |