1 回答
TA贡献1804条经验 获得超7个赞
我会在掩码内使用 SVG
.avatar-small {
width: 75px;
height: 75px;
padding: 4px;
}
.avatar-big {
width: 175px;
height: 175px;
padding: 10px;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
.avatar {
background-image: linear-gradient(to right, #9f7d5a, #d4b380 17%, #eecf97 41%, #b89a6a 62%, #dabd85 83%, #d4b380 100%);
}
.mask,
.mask > *{
-webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1 1"> <path d="M .5 0 C .1 0 0 .1 0 .5 0 .9 .1 1 .5 1 .9 1 1 .9 1 .5 1 .1 .9 0 .5 0 Z" /></svg>');
mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1 1"> <path d="M .5 0 C .1 0 0 .1 0 .5 0 .9 .1 1 .5 1 .9 1 1 .9 1 .5 1 .1 .9 0 .5 0 Z" /></svg>');
}
<div class="avatar avatar-small mask">
<img src="https://i.ibb.co/gycB3mQ/avatar.png">
</div>
<div class="avatar avatar-big mask">
<img src="https://i.ibb.co/gycB3mQ/avatar.png">
</div>
添加回答
举报