CSS mask-position Property
Example
Set the position of the mask layer image to center:
.mask1 {
-webkit-mask-image: url(w3logo.png);
mask-image: url(w3logo.png);
mask-size: 50%;
mask-repeat: no-repeat;
mask-position: center;
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The mask-position
property sets the starting
position of a mask image (relative to the
mask position area).
Tip: By default, a mask image is placed at the top-left corner of an element, and repeated both vertically and horizontally.
Default value: | 0% 0% |
---|---|
Inherited: | no |
Animatable: | no. Read about animatable |
Version: | CSS Masking Module Level 1 |
JavaScript syntax: | object.style.maskPosition="100px center" |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
mask-position | 120 | 120 | 53 | 15.4 | 106 |
CSS Syntax
mask-position: value;
Property Values
Value | Description |
---|---|
left top left center left bottom right top right center right bottom center top center center center bottom |
If you only specify one keyword, the other value will be "center" |
x% y% | The first value is the horizontal position and the second value is the vertical. The top left corner is 0% 0%. The right bottom corner is 100% 100%. If you only specify one value, the other value will be 50%. Default value is: 0% 0% |
xpos ypos | The first value is the horizontal position and the second value is the vertical. The top left corner is 0 0. Units can be pixels (0px 0px) or any other CSS units. If you only specify one value, the other value will be 50%. You can mix % and positions |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
More Examples
Example
Set the position of the mask layer image to right bottom corner:
.mask1 {
-webkit-mask-image: url(w3logo.png);
mask-image: url(w3logo.png);
mask-size: 50%;
mask-repeat: no-repeat;
mask-position: 100% 100%;
}
Try it Yourself »
Related Pages
CSS reference: mask property
CSS reference: mask-clip property
CSS reference: mask-composite property
CSS reference: mask-image property
CSS reference: mask-mode property
CSS reference: mask-origin property
CSS reference: mask-repeat property
CSS reference: mask-size property
CSS tutorial: CSS Masking