css-边框动画

一个css边框动画,感兴趣的可以看看

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!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>
* {
margin: 0;
padding: 0;
list-style: none;
--transition-duration: 500ms;
}

.box {
width: 500px;
height: 300px;
background-color: #000;
padding: 10px;
position: relative;
}

.box::before {
position: absolute;
content: '';
display: inline-block;
top: 10px;
left: 10px;
width: 0;
height: 1px;
background-color: #fff;
transition: all ease var(--transition-duration);
transition-delay: 0s;
}

.box::after {
position: absolute;
content: '';
display: inline-block;
bottom: 10px;
left: 10px;
width: 0;
height: 1px;
background-color: #fff;
transition: all ease var(--transition-duration);
transition-delay: calc(var(--transition-duration)/1.25);
}

.box div {
width: 100%;
height: 100%;
position: relative;
}

.content::before {
position: absolute;
content: '';
display: inline-block;
bottom: 0;
left: 0;
width: 1px;
height: 0;
background-color: #fff;
transition: all ease var(--transition-duration);
transition-delay: calc(var(--transition-duration)/1.25);
}

.content::after {
position: absolute;
content: '';
display: inline-block;
bottom: 0;
right: 0;
width: 1px;
height: 0;
background-color: #fff;
transition: all ease var(--transition-duration);
transition-delay: 0s;
}

.box:hover::after,
.box:hover::before {
width: 500px;
}

.content:hover::after,
.content:hover::before {
height: 100%;
}

.box:hover::before,
.content:hover::after {
transition-delay: calc(var(--transition-duration)/1.25);
}

.box:hover::after,
.content:hover::before {
transition-delay: 0s;
}
</style>
</head>

<body>
<div class="box">
<div class="content">
</div>
</div>
</body>

</html>