This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
Summary
The mask-repeat
CSS property defines how mask images are repeated. A mask image can be repeated along the horizontal axis, the vertical axis, both axes, or not repeated at all.
By default, the repeated images are clipped to the size of the element, but they can be scaled to fit (using round
) or evenly distributed from end to end (using space
).
Initial value | no-repeat |
---|---|
Applies to | all elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements |
Inherited | no |
Media | visual |
Computed value | Consists of two keywords, one per dimension |
Animatable | no |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
/* One-value syntax */ mask-repeat: repeat-x; mask-repeat: repeat-y; mask-repeat: repeat; mask-repeat: space; mask-repeat: round; mask-repeat: no-repeat; /* Two-value syntax: horizontal | vertical */ mask-repeat: repeat space; mask-repeat: repeat repeat; mask-repeat: round space; mask-repeat: no-repeat round; /* Global values */ mask-repeat: inherit; mask-repeat: initial; mask-repeat: unset;
Values
<repeat-style>
- The one-value syntax is a shorthand for the full two-value syntax:
-
Single value Two-value equivalent repeat-x
repeat no-repeat
repeat-y
no-repeat repeat
repeat
repeat repeat
space
space space
round
round round
no-repeat
no-repeat no-repeat
-
repeat
The image is repeated as much as needed to cover the whole mask painting area. The last image will be clipped if it doesn't fit. space
The image is repeated as much as possible without clipping. The first and last images are pinned to either side of the element, and whitespace is distributed evenly between the images. The mask-position
property is ignored unless only one image can be displayed without clipping. The only case where clipping happens usingspace
is when there isn't enough room to display one image.round
As the allowed space increases in size, the repeated images will stretch (leaving no gaps) until there is room for another one to be added. When the next image is added, all of the current ones compress to allow room. Example: An image with an original width of 260px, repeated three times, might stretch until each repetition is 300px wide, and then another image will be added. They will then compress to 225px. no-repeat
The image is not repeated (and hence the mask painting area will not necessarily be entirely covered). The position of the non-repeated mask image is defined by the mask-position
CSS property.
Formal syntax
<repeat-style>#where
<repeat-style> = repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
Example
FIXME:
Specifications
Specification | Status | Comment |
---|---|---|
CSS Masking Level 1 The definition of 'mask-repeat' in that specification. |
Candidate Recommendation | Initial definition |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | ? | No support[1] | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | No support[1] | ? | ? | ? |
[1] Gecko currently doesn't implement this feature. See bug 1251161.