使用语境
属性
height
-
此属性定义蒙版区域的高度。值类型:<length>;默认值:
120%
;可动画:是 mask-type
-
此属性定义
<mask>
内容的蒙版模式。值类型:alpha
|luminance
;默认值:luminance
;可动画:是 遮罩内容单位
-
此属性定义
<mask>
内容的坐标系。值类型:userSpaceOnUse
|objectBoundingBox
;默认值:userSpaceOnUse
;可动画:是 遮罩单位
-
此属性定义
<mask>
元素上x
、y
、width
和height
属性的坐标系。值类型:userSpaceOnUse
|objectBoundingBox
;默认值:objectBoundingBox
;可动画:是 x
-
此属性定义蒙版区域左上角的 x 轴坐标。值类型:<coordinate>;默认值:
-10%
;可动画:是 y
-
此属性定义蒙版区域左上角的 y 轴坐标。值类型:<coordinate>;默认值:
-10%
;可动画:是 width
-
此属性定义蒙版区域的宽度。值类型:<length>;默认值:
120%
;可动画:是
DOM 接口
此元素实现了 SVGMaskElement
接口。
示例
html
<svg viewBox="-10 -10 120 120">
<rect x="-10" y="-10" width="120" height="120" fill="blue" />
<mask id="myMask" mask-type="luminance">
<!-- Everything under a white pixel will be visible -->
<rect x="0" y="0" width="100" height="100" fill="white" />
<!-- Everything under a black pixel will be invisible -->
<path
d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z"
fill="black" />
</mask>
<polygon points="-10,110 110,110 110,-10" fill="orange" />
<!-- with this mask applied, we "punch" a heart shape hole into the circle -->
<circle cx="50" cy="50" r="50" fill="purple" mask="url(#myMask)" />
</svg>
规范
规范 |
---|
CSS 蒙版模块 Level 1 # MaskElement |
浏览器兼容性
加载中…
另见
- CSS
mask-type
属性 - 其他剪裁和蒙版 SVG 元素:
<clipPath>
- 剪裁和蒙版 CSS 属性:
mask
、mask-image
、mask-mode
、mask-repeat
、mask-position
、mask-clip
、mask-origin
、mask-composite
、mask-size