mask
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2023ë 12ì.
mask CSS ìì±ì ìì´í
ì´ ë¶ë¶ì ì¼ë¡ë§ ë³´ì¬ì§ê² íê±°ë í¹ì ìì í ê°ë ¤ì ë³´ì¬ì§ì§ ìê² í ì ìë 기ë¥ì ê°ì§ê³ ììµëë¤. ì´ ìì±ì ë§ì¤í¹ í¹ì í¹ì í ì ì 기ì¤ì¼ë¡ ì´ë¯¸ì§ë¥¼ ìë¼ë´ë 기ë¥ì í¨ê» ì ê³µí©ëë¤.
ì°¸ê³ :
mask ë mask-border를 ì´ê¸°ê°ì¼ë¡ ì¬ì ìí©ëë¤. ê·¸ë¬ë¯ë¡ ìºì¤ìºì´ë ì´ì ë¨ê³ì ì´ë í ë§ì¤í¬ ì¤ì ì ë®ì´ìì°ë ê°ë³ ìì±ìë ì¬í ë¤ë¥¸ ìì±ë³´ë¤ë mask 를 ì¬ì©íë ê²ì ì¶ì²í©ëë¤. This will ensure that mask-border has also been reset to allow the new styles to take effect.
| ì´ê¸°ê° | as each of the properties of the shorthand:
|
|---|---|
| ì ì©ëì | all elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements |
| ìì | no |
| Percentages | as each of the properties of the shorthand:
|
| ê³ì° ê° | as each of the properties of the shorthand:
|
| Animation type | as each of the properties of the shorthand:
|
| Creates stacking context | yes |
구문
/* í¤ìë ê° */
mask: none;
/* ì´ë¯¸ì§ ê° */
mask: url(mask.png); /* ë§ì¤í¬ë¡ ì¬ì©ëë ì´ë¯¸ì§ */
mask: url(masks.svg#star); /* ë§ì¤í¬ë¡ ì¬ì©ëë SVG ê·¸ëí½ ë´ ìì */
/* ì¡°í©í ê° */
mask: url(masks.svg#star) luminance; /* ë°ê¸° ì¡°ì ì© ë§ì¤í¬ë¡ ì¬ì©ëë SVG ê·¸ëí½ ë´ ìì */
mask: url(masks.svg#star) 40px 20px; /* ìë¡ë¶í° 40px, ìëë¶í° 20pxì ìì¹íë ë§ì¤í¬ë¡ ì¬ì©ëë SVG ê·¸ëí½ ë´ ìì */
mask: url(masks.svg#star) 0 0/50px 50px; /* ê°ë¡, ì¸ë¡ ê°ê° 50px ì¬ì´ì¦ì ë§ì¤í¬ë¡ ì¬ì©ëë SVG ê·¸ëí½ ë´ ìì */
mask: url(masks.svg#star) repeat-x; /* ìíì¼ë¡ ë°ë³µëë ë§ì¤í¬ë¡ ì¬ì©ëë SVG ê·¸ëí½ ë´ ìì */
mask: url(masks.svg#star) stroke-box; /* Element within SVG graphic used as mask extending to the box enclosed by the stroke */
mask: url(masks.svg#star) exclude; /* Element within SVG graphic used as mask and combined with background using non-overlapping parts */
/* ê¸ë¡ë² ê° */
mask: inherit;
mask: initial;
mask: unset;
ê°
<mask-reference>-
ë§ì¤í¬ ì´ë¯¸ì§ íì¼ ì¤ì í기.
mask-image를 íì¸íì¸ì. <masking-mode>-
ë§ì¤í¬ ì´ë¯¸ì§ì ë§ì¤í¹ 모ë ì¤ì í기.
mask-mode를 íì¸íì¸ì. <position>-
ë§ì¤í¬ ì´ë¯¸ì§ì ìì¹ ì¤ì í기.
mask-position를 íì¸íì¸ì. <bg-size>-
ë§ì¤í¬ ì´ë¯¸ì§ì í¬ê¸° ì¤ì í기.
mask-size를 íì¸íì¸ì. <repeat-style>-
ë§ì¤í¬ ì´ë¯¸ì§ì ë°ë³µ ì¤ì í기. See
mask-repeat를 íì¸íì¸ì. <geometry-box>-
ë¨ íëì <geometry-box> ê°ë§ 주ì´ì§ë¤ë©´
mask-originì(ê³¼)(mask-clip모ë ê°ì ê°ì¼ë¡ ì¤ì íë ê²ì ì미í©ëë¤. ëê°ì<geometry-box> ê°ì´ 주ì´ì§ë¤ë©´ 첫ë²ì§¸ ê°ìmask-originì(를), ëë²ì¨° ê°ìmask-clip를 ì¤ì íë ê²ì ì미í©ëë¤. <geometry-box> | no-clip-
ë§ì¤í¬ ì´ë¯¸ì§ì ìí¥ì ë°ë 구ìì ì¤ì í기.
mask-clip를 íì¸íì¸ì. <compositing-operator>-
íì¬ ë§ì¤í¬ ë ì´ì´ ìì í©ì± ì¤ì í기.
mask-composite를 íì¸íì¸ì.
íì 구문
mask =
<mask-layer>#
<mask-layer> =
<mask-reference> ||
<position> [ / <bg-size> ]? ||
<repeat-style> ||
<geometry-box> ||
[ <geometry-box> | no-clip ] ||
<compositing-operator> ||
<masking-mode>
<mask-reference> =
none |
<image> |
<mask-source>
<position> =
<position-one> |
<position-two> |
<position-four>
<bg-size> =
[ <length-percentage [0,â]> | auto ]{1,2} |
cover |
contain
<repeat-style> =
repeat-x |
repeat-y |
repeat-block |
repeat-inline |
<repetition>{1,2}
<geometry-box> =
<shape-box> |
fill-box |
stroke-box |
view-box
<compositing-operator> =
add |
subtract |
intersect |
exclude
<masking-mode> =
alpha |
luminance |
match-source
<image> =
<url> |
<image()> |
<image-set()> |
<cross-fade()> |
<element()> |
<gradient>
<mask-source> =
<url>
<position-one> =
left |
center |
right |
top |
bottom |
x-start |
x-end |
y-start |
y-end |
block-start |
block-end |
inline-start |
inline-end |
<length-percentage>
<position-two> =
[ left | center | right | x-start | x-end ] && [ top | center | bottom | y-start | y-end ] |
[ left | center | right | x-start | x-end | <length-percentage> ] [ top | center | bottom | y-start | y-end | <length-percentage> ] |
[ block-start | center | block-end ] && [ inline-start | center | inline-end ] |
[ start | center | end ]{2}
<position-four> =
[ [ left | right | x-start | x-end ] <length-percentage> ] && [ [ top | bottom | y-start | y-end ] <length-percentage> ] |
[ [ block-start | block-end ] <length-percentage> ] && [ [ inline-start | inline-end ] <length-percentage> ] |
[ [ start | end ] <length-percentage> ]{2}
<length-percentage> =
<length> |
<percentage>
<repetition> =
repeat |
space |
round |
no-repeat
<shape-box> =
<visual-box> |
margin-box |
half-border-box
<image()> =
image( <image-tags>? [ <image-src>? , <color>? ]! )
<image-set()> =
image-set( <image-set-option># )
<cross-fade()> =
cross-fade( <cf-image># )
<element()> =
element( <id-selector> )
<visual-box> =
content-box |
padding-box |
border-box
<image-tags> =
ltr |
rtl
<image-src> =
<url> |
<string>
<image-set-option> =
[ <image> | <string> ] [ <resolution> || type( <string> ) ]?
<cf-image> =
[ <image> | <color> ] &&
<percentage [0,100]>?
<id-selector> =
<hash-token>
ìì
.target {
mask: url(#c1) luminance;
}
.anothertarget {
mask: url(resources.svg#c1) 50px 30px/10px 10px repeat-x exclude;
}
ëª ì¸
| Specification |
|---|
| CSS Masking Module Level 1 > # the-mask > |