--- title: mask-mode slug: Web/CSS/mask-mode translation_of: Web/CSS/mask-mode ---
mask-mode
CSS属性指示由{{cssxref("mask-image")}} 指向的遮罩被视为亮度或阿尔法遮罩。
/* 关取值的键字 */ mask-mode: alpha; mask-mode: luminance; mask-mode: match-source; /* 多个类型的值 */ mask-mode: alpha, match-source; /* 全局变量的值 */ mask-mode: inherit; mask-mode: initial; mask-mode: unset;
{{cssinfo}}
下面列出 mask-mode
的一个或多个关键字值,以逗号分隔。
alpha
luminance
match-source
If the {{cssxref("mask-image")}} property is of type <mask-source>
, the luminance values of the mask layer image should be used as the mask values.
If it is of type {{cssxref("<image>")}}, the alpha values of the mask layer image should be used as the mask values.
如果{{cssxref("mask-image")}}属性是<mask-source>
类型,掩模层图像的亮度值会被作为掩模值。
如果它是类型{{cssxref("<image>")}},掩码层图像的alpha值应用作掩码值。
{{csssyntax}}
#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 */ }
<div id="masked"> </div> <select id="maskMode"> <option value="alpha">alpha</option> <option value="luminance">luminance</option> <option value="match-source">match-source</option> </select>
var maskMode = document.getElementById("maskMode"); maskMode.addEventListener("change", function (evt) { document.getElementById("masked").style.maskMode = evt.target.value; });
{{EmbedLiveSample("Example", 240, 240)}}
规范 | 状态 | 说明 |
---|---|---|
{{SpecName("CSS Masks", "#the-mask-mode", "mask-mode")}} | {{Spec2("CSS Masks")}} | Initial definition |
{{Compat("css.properties.mask-mode")}}