CSS mask-size Property
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-size property specifies the sizes of the mask images.
The size of the image can be fully or partially constrained in order to preserve its intrinsic ratio.
Default value: | auto |
Inherited: | No |
Animatable: | No |
Version: | CSS3 |
JavaScript syntax: |
|
Standard Syntax
mask-size: auto|size|contain|cover|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 |
---|---|
auto | This is default. A keyword that scales the mask image in the corresponding directions in order to maintain its intrinsic proportion. |
size | Specifies the size of the mask image in px, em, etc, or in %. |
contain | Scales the mask image in a way that both its width and its height fit inside the container. |
conver | Scales the mask image in a way that both its width and its height cover the container. |
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-size: auto;
}
More Examples
This is the mask image:
And this is an image of 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">