-
Notifications
You must be signed in to change notification settings - Fork 0
/
rain.html
54 lines (44 loc) · 1.13 KB
/
rain.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
<!DOCTYPE html>
<html lang="zh">
<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>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
body{
background: #333;
}
</style>
</head>
<body>
<script>
setInterval(function() {
var rain = document.createElement("div");
rain.style.position = "fixed";
rain.style.height = "150px";
rain.style.width = "2px";
rain.style.background = "#FFF";
rain.style.filter = "blur(1px)";
rain.style.top = "0px";
rain.style.left = Math.random() * 1920 + "px";
rain.style.opacity = parseInt(Math.random() * 10) / 10 + "";
document.body.appendChild(rain);
var timer = setInterval(function() {
var height = parseInt(rain.style.top);
var k = 1;
k++;
rain.style.top = height + Math.pow(k, 1.5) + "%";
if (parseInt(rain.style.top) >= 100) {
clearInterval(timer);
rain.parentNode.removeChild(rain);
}
}, 4)
}, 8)
</script>
</body>
</html>