-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.html
62 lines (57 loc) · 1.61 KB
/
1.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
<!DOCTYPE html>
<html>
<head>
<title>我们毕业了</title>
<style>
/* 定义动态爱心的样式 */
.heart {
position: absolute;
width: 100px;
height: 100px;
background-color: red;
transform: rotate(45deg);
animation: pulse 1s infinite;
}
/* 定义动画效果 */
@keyframes pulse {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.3);
opacity: 0.5;
}
100% {
transform: scale(1);
opacity: 1;
}
}
</style>
</head>
<body>
<h1>我们毕业了</h1>
<div class="heart"></div>
<script>
// 创建动态爱心元素
function createHeart() {
const heart = document.createElement("div");
heart.className = "heart";
document.body.appendChild(heart);
// 设置随机位置
const maxX = window.innerWidth - 100;
const maxY = window.innerHeight - 100;
const randomX = Math.floor(Math.random() * maxX);
const randomY = Math.floor(Math.random() * maxY);
heart.style.left = randomX + "px";
heart.style.top = randomY + "px";
// 移除动态爱心元素
setTimeout(() => {
document.body.removeChild(heart);
}, 2000);
}
// 定时创建动态爱心
setInterval(createHeart, 500);
</script>
</body>
</html>