-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
53 lines (48 loc) · 1.46 KB
/
index.html
File metadata and controls
53 lines (48 loc) · 1.46 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
<!DOCTYPE html>
<html>
<head>
<title>鸡打篮球</title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-size: 5em;
}
.basketball {
animation: bounce 1s infinite;
}
@keyframes bounce {
0% {
transform: translateY(0);
}
50% {
transform: translateY(-40px);
}
100% {
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="basketball">🏀</div>
<div class="chicken">🐔</div>
<script>
// 等待页面加载完成后再执行代码
document.addEventListener("DOMContentLoaded", function(event) {
var basketball = document.querySelector('.basketball');
var chicken = document.querySelector('.chicken');
basketball.addEventListener('click', function() {
// 添加一个随机的旋转角度
var rotation = Math.floor(Math.random() * 360);
basketball.style.transform = 'rotate(' + rotation + 'deg)';
});
chicken.addEventListener('click', function() {
chicken.style.animation = 'bounce 1s infinite';
});
});
</script>
</body>
</html>