-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
82 lines (81 loc) · 2.24 KB
/
index.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
74
75
76
77
78
79
80
81
82
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>设计学院: No.1 - 制作一个简单的菜单动画效果</title>
<style>
.container {
padding: 200px 0;
text-align: center;
}
.btn {
display: block;
padding: 5px 10px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
margin: 20px auto 0;
border: 1px solid #ccc;
}
.btn:hover {
cursor: pointer;
border-color: #0e9eff;
}
.btn:active {
color: #fff;
background-color: #0e9eff;
}
.btn:focus {
outline: none;
}
.text {
padding: 5px 0;
position: relative;
transition: color .5s;
}
.text:after {
left: 0;
right: 0;
width: 0;
bottom: 0;
content: '';
margin: 0 auto;
display: block;
position: absolute;
transition: width .5s;
transition-timing-function: ease-out;
-moz-transition-timing-function: ease-out;
-webkit-transition-timing-function: ease-out;
-o-transition-timing-function: ease-out;
border-bottom: 1px solid #0e9eff;
}
.text.animated {
color: #0e9eff;
}
.text.animated:after {
width: 100%;
}
</style>
<script>
function changeStyle ()
{
$text = document.getElementById('text');
$class = $text.getAttribute('class');
if ($class === 'text') {
$text.setAttribute('class', 'text animated');
} else {
$text.setAttribute('class', 'text');
}
}
</script>
</head>
<body>
<div class="container">
<span class="text" id="text">前端学院</span>
<button onclick="changeStyle()" class="btn">切换样式</button>
</div>
</body>
</html>