-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (66 loc) · 1.72 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Musical Keys</title>
</head>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #555;
}
body span {
width: 40px;
height: 40px;
background-color: #333;
text-align: center;
color: #eee;
padding: 20px;
margin: 0 auto;
border: 1px solid #eee;
cursor: pointer;
transition: all 200ms ease;
}
body span.active {
color: #333;
background-color: #eee;
border: none;
transform: scale(0.5);
transition: all 200ms ease;
}
</style>
<body>
<span>A</span>
<span>B</span>
<span>C</span>
<span>D</span>
<span>E</span>
<span>F</span>
<audio src="/24-piano-keys/key01.ogg"></audio>
<audio src="/24-piano-keys/key02.ogg"></audio>
<audio src="/24-piano-keys/key03.ogg"></audio>
<audio src="/24-piano-keys/key04.ogg"></audio>
<audio src="/24-piano-keys/key05.ogg"></audio>
<audio src="/24-piano-keys/key06.ogg"></audio>
</body>
<script>
let span = document.querySelectorAll('span')
let audio = document.querySelectorAll('audio')
span.forEach(function (e, i) {
e.onclick = function name() {
this.classList.add('active')
audio[i].play()
audio[i].playbackRate = 16
setTimeout(function () {
e.classList.remove('active')
}, 120)
}
})
</script>
</html>