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
|
---
title: mask-image
slug: Web/CSS/mask-image
translation_of: Web/CSS/mask-image
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>
<h2 id="概要">概要</h2>
<p><strong><code>mask-image</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a>属性用于设置元素上遮罩层的图像。</p>
<p>{{cssinfo}}</p>
<h2 id="语法">语法</h2>
<pre class="brush:css">/* Keyword value */
mask-image: none;
/* <mask-source> value */
mask-image: url(masks.svg#mask1);
/* <image< values */
mask-image: linear-gradient(rgba(0, 0, 0, 1.0), transparent);
mask-image: image(url(mask.png), skyblue);
/* Multiple values */
mask-image: image(url(mask.png), skyblue), linear-gradient(rgba(0, 0, 0, 1.0), transparent);
/* Global values */
mask-image: inherit;
mask-image: initial;
mask-image: unset;
</pre>
<h3 id="Values">Values</h3>
<dl>
<dt><code>none</code></dt>
<dd>默认值,透明的黑色图像层,也就是没有遮罩层。</dd>
<dt><code><mask-source></code></dt>
<dd><code><mask></code>或CSS图像的url</dd>
<dd>{{cssxref("<image>")}}</dd>
<dd>图片作为遮罩层</dd>
</dl>
<h3 id="Formal_syntax">Formal syntax</h3>
{{csssyntax}}
<h2 id="例子">例子</h2>
<h3 id="CSS">CSS</h3>
<pre class="brush: css; highlight[5]">#masked {
width: 100px;
height: 100px;
background-color: #8cffa0;
mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg);
-webkit-mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg);
}
</pre>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><div id="masked"></div>
</pre>
<p>{{EmbedLiveSample('例子', '100px', '100px')}}</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName("CSS Masks", "#the-mask-image", "mask-image")}}</td>
<td>{{Spec2("CSS Masks")}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("css.properties.mask-image")}}
|