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);
  -webkit-mask-size: 50%;
  mask-size: 50%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  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: CSS3
JavaScript syntax: object.style.maskPosition="100px center"

Browser Support

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

Numbers followed by -webkit- specify the first version that worked with a prefix.

Property
mask-position 4.0 -webkit- 79.0 -webkit- 53.0 4.0 -webkit- 15.0 -webkit-

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);
  -webkit-mask-size: 50%;
  mask-size: 50%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 100% 100%;
  mask-position: 100% 100%;
}
Try it Yourself »

Related Pages

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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.