This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The 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.
Initial value | border-box |
---|---|
Applies to | all elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | per grammar |
One or more of the keyword values listed below, separated by commas.
content-box
padding-box
0 0
is the upper left corner of the padding edge, 100% 100%
is the lower right corner.border-box
margin-box
fill-box
stroke-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
attribute.content
content-box
.padding
padding-box
.border
border-box
.<geometry-box>#where
<geometry-box> = <shape-box> | fill-box | stroke-box | view-boxwhere
<shape-box> = <box> | margin-boxwhere
<box> = border-box | padding-box | content-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 */ }
Specification | Status | Comment |
---|---|---|
CSS Masking Module Level 1 The definition of 'mask-origin' in that specification. | Candidate Recommendation | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes
|
? | 53 | ? | Yes
|
Yes
|
fill-box
|
No | ? | No | No | ? | ? |
stroke-box
|
No | ? | No | No | ? | ? |
view-box
|
No | ? | No | No | ? | ? |
Non-standard values content , padding , border
|
1
|
? | No | No | No | 4
|
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | ? | ? | 53 | ? | ? | ? |
fill-box
|
? | ? | ? | No | ? | ? | No |
stroke-box
|
? | ? | ? | No | ? | ? | No |
view-box
|
? | ? | ? | No | ? | ? | No |
Non-standard values content , padding , border
|
2
|
? | ? | No | ? | 3.2
|
? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/mask-origin