aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/background-blend-mode/index.html
blob: 77b621c4b12f43498ae70729e972e0222ec13b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: background-blend-mode
slug: Web/CSS/background-blend-mode
translation_of: Web/CSS/background-blend-mode
---
<p>{{CSSRef()}}</p>

<h2 id="Summary" name="Summary">概述</h2>

<p><code>background-blend-mode</code> CSS属性定义该元素的背景图片,以及背景色如何混合。</p>

<p>混合模式应该按{{cssxref("background-image")}} CSS属性同样的顺序定义。如果混合模式数量与背景图像的数量不相等,它会被截取至相等的数量。</p>

<p>{{cssinfo}}</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="twopartsyntaxbox"><code>Formal syntax:  {{csssyntax("background-blend-mode")}}</code></pre>

<pre>/* 单值 */
background-blend-mode: normal;

/* 双值,每个背景一个值 */
background-blend-mode: darken, luminosity;

background-blend-mode: initial;
background-blend-mode: inherit;
background-blend-mode: unset;
</pre>

<h3 id="Values" name="Values"><span style="font-style: inherit;"></span></h3>

<h3 id="Values" name="Values"><span style="font-family: consolas,monaco,andale mono,monospace; font-size: 14px; font-style: inherit; line-height: 1.5;">&lt;blend-mode&gt;</span></h3>

<dl>
 <dd>一个{{cssxref("&lt;blend-mode&gt;")}}定义混合的模式,可以有多个值,用逗号间隔。</dd>
</dl>

<h2 id="Examples" name="Examples">示例</h2>

&lt;select id="select"&gt;
    &lt;option&gt;normal&lt;/option&gt;
    &lt;option&gt;multiply&lt;/option&gt;
    &lt;option selected&gt;screen&lt;/option&gt;
    &lt;option&gt;overlay&lt;/option&gt;
    &lt;option&gt;darken&lt;/option&gt;
    &lt;option&gt;lighten&lt;/option&gt;
    &lt;option&gt;color-dodge&lt;/option&gt;
    &lt;option&gt;color-burn&lt;/option&gt;
    &lt;option&gt;hard-light&lt;/option&gt;
    &lt;option&gt;soft-light&lt;/option&gt;
    &lt;option&gt;difference&lt;/option&gt;
    &lt;option&gt;exclusion&lt;/option&gt;
    &lt;option&gt;hue&lt;/option&gt;
    &lt;option&gt;saturation&lt;/option&gt;
    &lt;option&gt;color&lt;/option&gt;
    &lt;option&gt;luminosity&lt;/option&gt;
&lt;/select&gt;</pre>

<pre class="brush: css" class="hidden">#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;
}</pre>

<pre class="brush: js" class="hidden">document.getElementById("select").onchange = function(event) {
    document.getElementById("div").style.backgroundBlendMode = document.getElementById("select").selectedOptions[0].innerHTML;
}
console.log(document.getElementById('div'));</pre>

<p>{{ EmbedLiveSample('Examples', "330", "330") }}</p>

<h2 id="Specifications" name="Specifications">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('Compositing', '#background-blend-mode', 'background-blend-mode') }}</td>
   <td>{{ Spec2('Compositing') }}</td>
   <td>首次定义</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>

{{Compat("css.properties.background-blend-mode")}}

<h2 id="See_also" name="See_also">参见</h2>

<ul>
 <li>{{cssxref("&lt;blend-mode&gt;")}}</li>
 <li>{{cssxref("mix-blend-mode")}}</li>
</ul>