CSS - mask-origin

The mask-origin CSS property determines the origin of a mask.

Example

 

CSS Content

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

Syntax  

CSS
/* 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;

Values

content-box
The position is relative to the content box.
padding-box
The position is relative to the padding box. For single boxes 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
Uses the nearest SVG viewport as reference box. If a 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
Same as content-box.
padding
Same as padding-box.
border
Same as border-box.

Formal syntax

CSS
<a href="css/mask-origin#geometry-box"><geometry-box></a><a title="Hash mark" href="css/value_definition_syntax#hash_mark_(.23)">#</a><p>where <br><code><geometry-box> = <a href="css/mask-origin#shape-box"><shape-box></a> <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> fill-box <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> stroke-box <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> view-box</code></p><p>where <br><code><shape-box> = <a href="css/mask-origin#box"><box></a> <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> margin-box</code></p><p>where <br><code><box> = border-box <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> padding-box <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> content-box</code></p>

Description  

The mask-origin CSS property determines the origin of a mask.

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 valueborder-box
Applies toall elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Inheritedno
Mediavisual
Computed valueas specified
Animatableno
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Edge Opera Safari (WebKit)
Basic support (Yes)-webkit[1] No support[2] ? ? (Yes)-webkit[1] (Yes)-webkit[1]
fill-box, stroke-box, view-box No support No support ? ? ? ?
content, padding, border 1.0-webkit No support No support ? No support 4.0-webkit
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? No support[1] ? ? ?
fill-box, stroke-box, view-box ? No support ? ? ?
content, padding, border 2.1-webkit No support ? ? 3.2-webkit

[1] WebKit and Blink currently don't support the value margin-box.

[2] Gecko currently doesn't implement this feature. See bug 1251161.

Specifications  

Specification Status Comment
CSS Masking Level 1
The definition of 'mask-origin' in that specification.
Candidate Recommendation Initial definition

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/mask-origin

CSS CSS Masks CSS Property Reference