-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton-word.html
70 lines (62 loc) · 1.48 KB
/
button-word.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
<!DOCTYPE html>
<html lang="en">
<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">
<title>button 文字动效</title>
<style type="text/css">
html, body {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.box {
width: 200px;
height: 60px;
border: 2px solid black;
text-align: center;
font-size: 30px;
line-height: 60px;
font-family: sans-serif;
overflow: hidden;
}
.box span {
display: inline-block;
color: blue;
transition: 0.5s;
}
.box span:nth-child(odd) {
transform: translateY(-100%);
}
.box span:nth-child(even) {
transform: translateY(100%);
}
.box span::before {
content: attr(data-text);
position: absolute;
color: red;
}
.box span:nth-child(odd)::before {
transform: translateY(100%);
}
.box span:nth-child(even)::before {
transform: translateY(-100%);
}
.box:hover span {
transform: translateY(0);
}
</style>
</head>
<body>
<div class="box">
<span data-text="B">B</span>
<span data-text="U">U</span>
<span data-text="T">T</span>
<span data-text="T">T</span>
<span data-text="O">O</span>
<span data-text="N">N</span>
</div>
</body>
</html>