mask-type
CSS
property sets whether an SVG
<mask>
element is used as a
luminance
or an
alpha
mask. It applies to the
<mask>
element itself.
/* Keyword values */ mask-type: luminance; mask-type: alpha; /* Global values */ mask-type: inherit; mask-type: initial; mask-type: unset;
This property may be overridden by the
mask-mode
property, which has the same effect but applies to the element where the mask is used. Alpha masks will generally be faster to render.
mask-type
property is specified as one of the keyword values listed below.
luminance
alpha
| 初始值 |
luminance
|
|---|---|
| 适用于 |
<mask>
elements
|
| 继承 | no |
| 计算值 | 如指定 |
| 动画类型 | discrete |
luminance | alpha
<div class="redsquare"></div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">
<defs>
<mask id="m" maskContentUnits="objectBoundingBox"
style="mask-type:alpha">
<rect x=".1" y=".1" width=".8" height=".8"
fill="red" fill-opacity="0.7"/>
</mask>
</defs>
</svg>
.redsquare {
height: 100px;
width: 100px;
background-color: rgb(128, 128, 128);
border: solid 1px black;
mask: url("#m");
}
<div class="redsquare"></div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">
<defs>
<mask id="m" maskContentUnits="objectBoundingBox"
style="mask-type:luminance">
<rect x=".1" y=".1" width=".8" height=".8"
fill="red" fill-opacity="0.7"/>
</mask>
</defs>
</svg>
.redsquare {
height: 100px;
width: 100px;
background-color: rgb(128, 128, 128);
border: solid 1px black;
mask: url("#m");
mask-type:luminance;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Masking Module Level 1
The definition of 'mask-type' in that specification. |
候选推荐 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mask-type
|
Chrome 完整支持 24 | Edge 完整支持 79 |
Firefox
完整支持
35
|
IE 不支持 No | Opera 完整支持 15 | Safari 完整支持 6.1 | WebView Android 完整支持 37 | Chrome Android 完整支持 25 |
Firefox Android
完整支持
35
|
Opera Android 完整支持 14 | Safari iOS 完整支持 7 | Samsung Internet Android 完整支持 1.5 |
完整支持
不支持
用户必须明确启用此特征。