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.
img {
mask-image: url(/images/htmhell_logo.svg);
}
There are a bunch of properties you can use to adjust the styling of the mask.
- mask-clip (MDN)
- mask-composite (MDN)
- mask-image (MDN)
- mask-mode (MDN)
- mask-origin (MDN)
- mask-position (MDN)
- mask-repeat (MDN)
- mask-size (MDN)
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;
}
-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ć
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.