forked from chuyueZhang/frontEndLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpianoPrac.html
More file actions
82 lines (81 loc) · 2.24 KB
/
pianoPrac.html
File metadata and controls
82 lines (81 loc) · 2.24 KB
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="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>音阶练习</title>
<style>
*{
margin: 0;
padding: 0;
}
.wrap{
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 20%;
}
ul{
border: 1px solid black;
list-style: none;
overflow: hidden;
}
li{
line-height: 30px;
text-align: center;
float: left;
width: 70px;
height: 30px;
border-right: 1px solid black;
overflow: hidden;
position: relative;
}
li:nth-child(7){
border-right: none;
}
.nav div{
position: absolute;
top: 30px;
width: 70px;
height: 30px;
background-color: #ccc;
z-index: -1;
transition: .5s;
}
</style>
</head>
<body>
<audio></audio>
<div class="wrap">
<ul class="nav">
<li class="a">a<div></div></li>
<li class="b">b<div></div></li>
<li class="c">c<div></div></li>
<li class="d">d<div></div></li>
<li class="e">e<div></div></li>
<li class="f">f<div></div></li>
<li class="g">g<div></div></li>
</ul>
</div>
</body>
<script>
window.onload = function(){
var lis = document.getElementsByClassName('nav')[0].children
var audio = document.getElementsByTagName('audio')[0]
for(var i=0; i<lis.length; i++){
lis[i].onmouseenter = function(){
audio.src = 'http://s8.qhimg.com/share/audio/piano1/'+this.className+'4.mp3'
audio.play()
var div = this.children[0]
div.style.top='0px'
div.addEventListener('transitionend', up)
function up(){
div.style.top='30px'
div.removeEventListener('transitionend', up)
}
}
}
}
</script>
</html>