<section class="mask-example">
  <div class="box box1">
    <figure>
      <img src="https://fruntend.com/storage/photos/1/sunflowers.jpg" alt="sunflower">
    </figure>
    <div class="figcaption">
      mask-image: url(mask.png)
    </div>
  </div>
  <div class="box box2">
    <figure>
      <img src="https://fruntend.com/storage/photos/1/zach-miles-Y84.jpg" alt="city">
    </figure>
    <div class="figcaption">
      mask-image: url(mask.svg)
    </div>
  </div>
</section>
* {
  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: calc(25% - 15px);
}
.mask-example .box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.mask-example .box figure {
  -webkit-mask-size: 100%;
  -webkit-mask-repeat: no-repeat;
}
.mask-example .box1 figure {
  -webkit-mask-image: url(https://fruntend.github.io/images/examples/rate_star_icon.png);
}
.mask-example .box2 figure {
  -webkit-mask-image: url(https://fruntend.github.io/images/examples/picture_icon.svg);
}
@media screen and (max-width: 600px) {
  .mask-example {
    flex-wrap: wrap;
  }
  .mask-example .box {
    width: calc(50% - 10px);
  }
}
.figcaption {
  background: #ffedc5;
  border: 1px solid #777;
  padding: 10px;
  text-align: center;
  font-family: monospace;
  font-size: 14px;
  border-radius: 3px;
  margin-top: 10px;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.