Day 87: mask properties

You can use mask properties to apply a mask to an element.

Let’s say you have an image and a logo. You can use the logo to mask the image.

a huge fire. multiple large palettes burning.
HTMHell logo

img {
mask-image: url(/images/htmhell_logo.svg);
}

There are a bunch of properties you can use to adjust the styling of the mask.

img {
mask-image: url(/images/htmhell_logo.svg);
mask-size: cover;
mask-repeat: no-repeat;
mask-position: center;
}

You can also apply a mask to an element.

div {
max-width: 400px;
aspect-ratio: 1;
background-color: red;

mask-image: url(/images/htmhell_logo.svg);
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
}
Note: You need the -webkit- prefix for some browsers.

My blog doesn’t support comments yet, but you can reply via blog@matuzo.at.


This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović

You can use mask properties to apply a mask to an element.

Let's say you have an image and a logo. You can use the logo to mask the image.

a huge fire. multiple large palettes burning. HTMHell logo
img {
mask-image: url(/images/htmhell_logo.svg);
}

There are a bunch of properties you can use to adjust the styling of the mask.

img {
mask-image: url(/images/htmhell_logo.svg);
mask-size: cover;
mask-repeat: no-repeat;
mask-position: center;
}

You can also apply a mask to an element.

div {
max-width: 400px;
aspect-ratio: 1;
background-color: red;

mask-image: url(/images/htmhell_logo.svg);
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
}
Note: You need the -webkit- prefix for some browsers.

My blog doesn't support comments yet, but you can reply via blog@matuzo.at.


This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović


Print Share Comment Cite Upload Translate Updates
APA

Manuel Matuzović | Sciencx (2023-01-24T09:38:54+00:00) Day 87: mask properties. Retrieved from https://www.scien.cx/2023/01/24/day-87-mask-properties/

MLA
" » Day 87: mask properties." Manuel Matuzović | Sciencx - Tuesday January 24, 2023, https://www.scien.cx/2023/01/24/day-87-mask-properties/
HARVARD
Manuel Matuzović | Sciencx Tuesday January 24, 2023 » Day 87: mask properties., viewed ,<https://www.scien.cx/2023/01/24/day-87-mask-properties/>
VANCOUVER
Manuel Matuzović | Sciencx - » Day 87: mask properties. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/24/day-87-mask-properties/
CHICAGO
" » Day 87: mask properties." Manuel Matuzović | Sciencx - Accessed . https://www.scien.cx/2023/01/24/day-87-mask-properties/
IEEE
" » Day 87: mask properties." Manuel Matuzović | Sciencx [Online]. Available: https://www.scien.cx/2023/01/24/day-87-mask-properties/. [Accessed: ]
rf:citation
» Day 87: mask properties | Manuel Matuzović | Sciencx | https://www.scien.cx/2023/01/24/day-87-mask-properties/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.