CSS mask-position Property

❮ Previous Reference Next ❯

Example

.example {
  -webkit-mask-image: url(hello-world.png);
  mask-image: url(hello-world.png);
  -webkit-mask-size: 60%;
  mask-size: 60%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center; 
}

Meaning

The mask-position property sets the initial position, relative to the mask position layer set by mask-origin, for each defined mask image.

Default value:0% 0%
Inherited:No
Animatable:No
Version:CSS3
JavaScript syntax:
object.style.maskPosition="value";



Standard Syntax

mask-position: value;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property.

Value Description
left top
left bottom
right center
right bottom
center top
right top
center bottom
center center
left center
If only one keyword specified, than other value will be "center".
x% y% Specifies 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 Specifies 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.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  mask-position: 0% 0%;
}



More Examples

This is the mask image:

hello-world

And this is an image of flowers:

flowers

After apply the mask image as the mask layer for the image flowers:


Example

<style type="text/css">
img {
  -webkit-mask-image: url(hello-world.png);
  mask-image: url(hello-world.png);
  -webkit-mask-size: 100%;
  mask-size: 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
</style>

<img src="flowers.jpg" width="200" height="200">
❮ Previous Reference Next ❯