在线文档教程
CSS

面具模型 | mask-mode

mask-mode

这是一种实验技术

由于本技术规范未稳定,请检查各种浏览器使用的兼容性表。还要注意,随着规范的改变,实验技术的语法和行为也会随着浏览器未来版本的变化而变化。

mask-modeCSS属性指示是否由mask-image被视为亮度或阿尔法遮罩。

/* Keyword values */ mask-mode: alpha; mask-mode: luminance; mask-mode: match-source; /* Multiple values */ mask-mode: alpha, match-source; /* Global values */ mask-mode: inherit; mask-mode: initial; mask-mode: unset;

Initial valuematch-source
Applies toall elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Inheritedno
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

语法

下面列出的一个或多个关键字值,以逗号分隔。

alpha此关键字指示应使用掩码层图像的透明度(阿尔法通道)值作为掩码值。

如果mask-image属性是<mask-source>类型,掩模层图像的亮度值会被作为掩模值。

如果它是类型<image>,掩码层图像的alpha值应用作掩码值。

形式语法

<masking-mode>#where <masking-mode> = alpha | luminance | match-source

CSS内容

#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 */ }

规格

SpecificationStatusComment
CSS Masking Module Level 1The definition of 'mask-mode' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerEdgeOperaSafari (WebKit)
Basic supportNo support53.0 (53.0)No support?No supportNo support

FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic supportNo support53.0 (53.0)No supportNo supportNo support