遮罩层动画

image-20240127145410062

  • 也是相当于两层
  • 下面那层一开始不显示opacity:0,当鼠标滑过的时候opacity:0.4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
display: inline-block;
width: 227px;
height: 309px;
border: 4px solid white;
box-shadow: 0 0 10px black;
border-radius: 50%;
overflow: hidden;
position: relative;
}
.box img {
width: 100%;
height: 100%;
}
.box:hover .cover{
opacity: 0.4;
transform: scale(2);
}
.cover {
position: absolute;
left: 0;
top: 0;
width: 227px;
height: 309px;
line-height: 309px;
border-radius: 50%;
text-align: center;
font-size: 50px;
background-color: black;
color: white;
opacity: 0;
transform: scale(0);
transition: all 1s ease;
}
</style>
</head>
<body>
<div class="box">
<img src="../img/baby.jpg" alt="">
<div class="cover">Baby</div>
</div>
<div class="box">
<img src="../img/baby.jpg" alt="">
<div class="cover">Baby</div>
</div>
<div class="box">
<img src="../img/baby.jpg" alt="">
<div class="cover">Baby</div>
</div>
<div class="box">
<img src="../img/baby.jpg" alt="">
<div class="cover">Baby</div>
</div>
<div class="box">
<img src="../img/baby.jpg" alt="">
<div class="cover">Baby</div>
</div>
</body>
</html>