mask-composite CSS property represents a compositing operation used on the current mask layer with the mask layers below it.

/* Keyword values */
mask-composite: add;
mask-composite: subtract;
mask-composite: intersect;
mask-composite: exclude;
/* Global values */
mask-composite: inherit;
mask-composite: initial;
mask-composite: unset;
					

句法

One or more of the keyword values listed below, separated by commas.

For the composition the current mask layer is referred to as source , while all layers below it are referred to as destination .

add

The source is placed over the destination.

subtract

The source is placed, where it falls outside of the destination.

intersect

The parts of source that overlap the destination, replace the destination.

exclude

The non-overlapping regions of source and destination are combined.

形式定义

初始值 add
适用于 all elements; In SVG, it applies to container elements excluding the defs element and all graphics elements
继承 no
计算值 如指定
动画类型 discrete

形式句法

<compositing-operator>#

where
<compositing-operator> = add | subtract | intersect | exclude

范例

Compositing mask layers with addition

CSS

#masked {
  width: 100px;
  height: 100px;
  background-color: #8cffa0;
  mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg),
              url(https://mdn.mozillademos.org/files/12676/star.svg);
  mask-size: 100% 100%;
  mask-composite: add; /* Can be changed in the live sample */
}
					

HTML

<div id="masked">
</div>
<select id="compositeMode">
  <option value="add">add</option>
  <option value="subtract">subtract</option>
  <option value="intersect">intersect</option>
  <option value="exclude">exclude</option>
</select>
					

JavaScript

var clipBox = document.getElementById("compositeMode");
clipBox.addEventListener("change", function (evt) {
  document.getElementById("masked").style.maskComposite = evt.target.value;
});
					

结果

规范

规范 状态 注释
CSS Masking Module Level 1
The definition of 'mask-composite' in that specification.
候选推荐 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
mask-composite Chrome 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Edge 不支持 18 — 79 Firefox 完整支持 53 IE 不支持 No Opera 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Safari 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
WebView Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Chrome Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Firefox Android 完整支持 53 Opera Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Safari iOS 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.
Samsung Internet Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 另请参阅 -webkit-mask-composite for a similar non-standard property that uses different keywords.

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

见实现注意事项。

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Masking
  4. 特性
    1. clip
    2. clip-path
    3. mask
    4. mask-border
    5. mask-border-mode
    6. mask-border-outset
    7. mask-border-repeat
    8. mask-border-slice
    9. mask-border-source
    10. mask-border-width
    11. mask-clip
    12. mask-composite
    13. mask-image
    14. mask-mode
    15. mask-origin
    16. mask-position
    17. mask-repeat
    18. mask-size
    19. mask-type

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1