<section class="mask-example">
<div class="box">
<figure>
<img src="https://fruntend.com/storage/photos/1/sunflowers.jpg" alt="sunflower">
</figure>
</div>
</section>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
padding: 20px;
}
.mask-example {
width: 100%;
display: flex;
justify-content: center;
gap: 20px;
align-items: flex-start;
}
.mask-example figure {
aspect-ratio: 1/1;
}
.mask-example .box {
width: 100%;
max-width: 340px;
}
.mask-example .box img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}
.figcaption {
background: #ffedc5;
border: 1px solid #777;
padding: 10px;
text-align: center;
font-family: monospace;
font-size: 14px;
border-radius: 3px;
margin-top: 10px;
}
</style>
.mask-example .box figure {
-webkit-mask-size: 50% auto;
-webkit-mask-position: 50% 0;
-webkit-mask-repeat: repeat;
-webkit-mask-image: url(https://fruntend.github.io/images/examples/rate_star_icon.png);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.