效果例图:
1、html代码如下:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="./3.css" />
<title>Document</title>
</head>
<body>
<div class="avatar"></div>
</body>
</html>
2、css3代码展示:
.avatar{
background: url('https://s21.ax1x.com/2024/06/01/pkGVtV1.jpg') no-repeat center center;
background-size: cover;
width: 100px;
height: 100px;
border-radius: 50%;
margin: 0 auto;
display: block;
margin-bottom: 10px;
border: 1px solid #eee;
position: relative;
}
.avatar::before,.avatar::after{
content: '';
position: absolute;
top: 0;
left: 0;
width: inherit;
height: inherit;
border-radius: 50%;
transition: all 0.3s;
}
.avatar::before{
background: rgba(0, 0, 0,0.5)
}
.avatar::after{
background: inherit;
clip-path: circle(0% at 50% 50%);
}
.avatar:hover::after{
clip-path: circle(100% at 50% 50%);
}