<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-origin: border-box
</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-origin: padding-box
</div>
</div>
<div class="box box3">
<figure>
<img src="https://fruntend.com/storage/photos/1/sonnie-hiles.jpg" alt="city">
</figure>
<div class="figcaption">
mask-origin: content-box
</div>
</div>
</section>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
padding: 20px;
}
.mask-example {
width: 100%;
display: flex;
gap: 20px;
align-items: flex-start;
}
.mask-example figure {
aspect-ratio: 1/1;
}
.mask-example .box {
width: calc(33.333% - 10px);
}
.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;
-webkit-mask-image: radial-gradient(ellipse 25% 25% at 25% 25%, transparent 100%, #000 0);
border: 20px solid #000;
background-color: green;
padding: 20px;
}
.mask-example .box1 figure {
-webkit-mask-origin: border-box;
}
.mask-example .box2 figure {
-webkit-mask-origin: padding-box;
}
.mask-example .box3 figure {
-webkit-mask-origin: content-box;
}
@media screen and (max-width: 600px) {
.mask-example {
flex-wrap: wrap;
}
.mask-example .box {
width: 100%;
}
}
.figcaption {
background: #ffedc5;
border: 1px solid #777;
padding: 10px;
text-align: center;
font-family: monospace;
font-size: 14px;
border-radius: 3px;
margin-top: 10px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.