aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/mask-mode/index.html
blob: f533a8e18de3e1aa539a4b3e830a59b8595eaa7d (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
103
104
105
106
107
108
109
110
111
112
113
114
---
title: mask-mode
slug: Web/CSS/mask-mode
translation_of: Web/CSS/mask-mode
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>

<p><strong><code>mask-mode</code></strong><a href="https://developer.mozilla.org/en-US/docs/Web/CSS" rel="nofollow noopener noreferrer">CSS</a>属性指示由{{cssxref("mask-image")}} 指向的遮罩被视为亮度或阿尔法遮罩。</p>

<pre class="brush:css no-line-numbers">/* 关取值的键字 */
mask-mode: alpha;
mask-mode: luminance;
mask-mode: match-source;

/* 多个类型的值 */
mask-mode: alpha, match-source;

/* 全局变量的值 */
mask-mode: inherit;
mask-mode: initial;
mask-mode: unset;
</pre>

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

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

<p>下面列出 <code>mask-mode</code> 的一个或多个关键字值,以逗号分隔。</p>

<h3 id="Values">Values</h3>

<dl>
 <dt><code>alpha</code></dt>
 <dd>此关键字指示应使用掩码层图像的透明度(阿尔法通道)值作为掩码值。</dd>
 <dt><code>luminance</code></dt>
 <dd>此关键字指示掩膜层图像的亮度值应用作掩码值。</dd>
 <dt><code>match-source</code></dt>
 <dd>
 <p>If the {{cssxref("mask-image")}} property is of type <code>&lt;mask-source&gt;</code>, the luminance values of the mask layer image should be used as the mask values.</p>

 <p>If it is of type {{cssxref("&lt;image&gt;")}}, the alpha values of the mask layer image should be used as the mask values.</p>

 <p>如果{{cssxref("mask-image")}}属性是<code>&lt;mask-source&gt;</code>类型,掩模层图像的亮度值会被作为掩模值。</p>

 <p>如果它是类型{{cssxref("&lt;image&gt;")}},掩码层图像的alpha值应用作掩码值。</p>
 </dd>
</dl>

<h3 id="正式语法">正式语法</h3>

{{csssyntax}}

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

<h3 id="CSS">CSS</h3>

<pre class="brush: css; highlight[6]">#masked {
  width: 227px;
  height: 200px;
  background: blue linear-gradient(red, blue);
  mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg);
  mask-mode: alpha; /* Can be changed in the live sample */
}
</pre>

<div class="hidden">
<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;div id="masked"&gt;
&lt;/div&gt;
&lt;select id="maskMode"&gt;
  &lt;option value="alpha"&gt;alpha&lt;/option&gt;
  &lt;option value="luminance"&gt;luminance&lt;/option&gt;
  &lt;option value="match-source"&gt;match-source&lt;/option&gt;
&lt;/select&gt;
</pre>

<h3 id="JavaScript">JavaScript</h3>

<pre class="brush: js">var maskMode = document.getElementById("maskMode");
maskMode.addEventListener("change", function (evt) {
  document.getElementById("masked").style.maskMode = evt.target.value;
});
</pre>
</div>

<h3 id="结果">结果</h3>

<p>{{EmbedLiveSample("Example", 240, 240)}}</p>

<h2 id="规范">规范</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("CSS Masks", "#the-mask-mode", "mask-mode")}}</td>
   <td>{{Spec2("CSS Masks")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("css.properties.mask-mode")}}</p>