-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path基于transition-delay的边框长度变化动画(圆).html
73 lines (69 loc) · 1.76 KB
/
基于transition-delay的边框长度变化动画(圆).html
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
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<!-- 核心在于通过元素先高度后宽度的变化,让四条 border 的出现是有先后顺序的 -->
<style>
div {
position: relative;
width: 200px;
height: 64px;
line-height: 64px;
box-shadow: inset 0 0 0 3px #ddd;
margin: 50px auto;
text-align: center;
color: #333;
font-size: 16px;
cursor: pointer;
transition: color 1s;
overflow: hidden;
}
div::before,
div::after {
content: '';
position: absolute;
width: 0;
height: 0;
top: 0;
left: 0;
box-sizing: border-box;
border: 3px solid transparent;
}
.circle {
width: 120px;
height: 120px;
line-height: 120px;
border-radius: 50%;
}
.circle::before,
.circle::after {
border-radius: 50%;
}
.circle:hover {
color: #00e2ff;
}
.circle:hover::before {
width: 120px;
height: 120px;
border-color: #00e2ff;
transition: border-top-color 0.25s linear,
border-right-color 0.25s linear, border-bottom-color 0.25s linear,
border-left-color 0.25s linear;
transition-delay: 0s, 0.25s, 0.5s, 0.75s;
}
.circle:hover::after {
width: 120px;
height: 120px;
border-top: 3px solid #00e2ff;
transform: rotate(270deg);
transition: transform 0.75s linear;
transition-delay: 0s;
}
</style>
</head>
<body>
<div class="circle">Circle</div>
</body>
</html>