mask-origin
CSS
property sets the origin of a mask.
/* Keyword values */ mask-origin: content-box; mask-origin: padding-box; mask-origin: border-box; mask-origin: margin-box; mask-origin: fill-box; mask-origin: stroke-box; mask-origin: view-box; /* Multiple values */ mask-origin: padding-box, content-box; mask-origin: view-box, fill-box, border-box; /* Non-standard keyword values */ -webkit-mask-origin: content; -webkit-mask-origin: padding; -webkit-mask-origin: border; /* Global values */ mask-origin: inherit; mask-origin: initial; mask-origin: unset;
For elements rendered as a single box, this property specifies the mask positioning area. In other words, this property specifies the origin position of an image specified by the
mask-image
CSS property. For elements rendered as multiple boxes, such as inline boxes on several lines or boxes on several pages, it specifies which boxes
box-decoration-break
operates upon to determine the mask positioning area.
One or more of the keyword values listed below, separated by commas.
content-box
The position is relative to the content box.
padding-box
0 0
is the upper left corner of the padding edge,
100% 100%
is the lower right corner.
border-box
The position is relative to the border box.
margin-box
The position is relative to the margin box.
fill-box
The position is relative to the object bounding box.
stroke-box
The position is relative to the stroke bounding box.
view-box
viewBox
attribute is specified for the element creating the SVG viewport, the reference box is positioned at the origin of the coordinate system established by the
viewBox
attribute and the dimension of the reference box is set to the width and height values of the
viewBox
属性。
content
content-box
.
padding
padding-box
.
border
border-box
.
| 初始值 |
border-box
|
|---|---|
| 适用于 |
all elements; In SVG, it applies to container elements excluding the
defs
element and all graphics elements
|
| 继承 | no |
| 计算值 | 如指定 |
| 动画类型 | discrete |
<geometry-box>#where
<geometry-box> = <shape-box> | fill-box | stroke-box | view-box
#masked {
width: 100px;
height: 100px;
margin: 10px;
border: 10px solid blue;
background-color: #8cffa0;
padding: 10px;
mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg);
mask-origin: border-box; /* Can be changed in the live sample */
}
<div id="masked"> </div> <select id="origin"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box</option> </select>
var origin = document.getElementById("origin");
origin.addEventListener("change", function (evt) {
document.getElementById("masked").style.maskOrigin = evt.target.value;
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Masking Module Level 1
The definition of 'mask-origin' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mask-origin
|
Chrome
完整支持
1
Prefixed
注意事项
|
Edge
完整支持
79
Prefixed
注意事项
|
Firefox
完整支持
53
|
IE 不支持 No |
Opera
完整支持
15
Prefixed
注意事项
|
Safari
完整支持
4
Prefixed
注意事项
|
WebView Android
完整支持
2
Prefixed
注意事项
|
Chrome Android
完整支持
18
Prefixed
注意事项
|
Firefox Android
完整支持
53
|
Opera Android
完整支持
14
Prefixed
注意事项
|
Safari iOS
完整支持
3.2
Prefixed
注意事项
|
Samsung Internet Android
完整支持
1.0
Prefixed
注意事项
|
fill-box
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
Non-standard values
content
,
padding
,
border
非标
|
Chrome
完整支持
1
Prefixed
|
Edge
完整支持
79
Prefixed
|
Firefox 不支持 No | IE 不支持 No |
Opera
完整支持
15
Prefixed
|
Safari
完整支持
4
Prefixed
|
WebView Android
完整支持
2
Prefixed
|
Chrome Android
完整支持
18
Prefixed
|
Firefox Android 不支持 No |
Opera Android
完整支持
14
Prefixed
|
Safari iOS
完整支持
3.2
Prefixed
|
Samsung Internet Android
完整支持
1.0
Prefixed
|
stroke-box
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
view-box
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
完整支持
不支持
非标。预期跨浏览器支持较差。
见实现注意事项。
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。