CSS mask-image 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;    
}

Meaning

The mask-image property sets the image that is used as mask layer for an element.

Default value:none
Inherited:No
Animatable:No
Version:CSS3
JavaScript syntax:
object.style.maskImage="none|image|url|initial|inherit|revert|revert-layer|unset";



Standard Syntax

mask-image: none|image|url|initial|inherit|revert|revert-layer|unset;



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
none This is default. No mask image in set.
image Specifies the image to use as the mask layer.
url Specifies the url reference to an image or an SVG <mask> element.
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-image: none;
}



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 ❯