-
Notifications
You must be signed in to change notification settings - Fork 0
/
blackhole.html
63 lines (61 loc) · 1.68 KB
/
blackhole.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Black Hole with Stars</title>
<style>
body {
margin: 0;
padding: 0;
background-color: black;
overflow: hidden;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.black-hole {
width: 200px;
height: 200px;
background: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 70%);
border-radius: 50%;
position: relative;
z-index: 10;
}
.star {
width: 2px;
height: 2px;
background-color: white;
border-radius: 50%;
position: absolute;
animation: twinkle 2s infinite;
}
@keyframes twinkle {
0%, 100% {
opacity: 0.2;
}
50% {
opacity: 1;
}
}
</style>
</head>
<body>
<div class="black-hole"></div>
<script>
const body = document.body;
function createStar() {
const star = document.createElement('div');
star.classList.add('star');
star.style.top = Math.random() * window.innerHeight + 'px';
star.style.left = Math.random() * window.innerWidth + 'px';
star.style.animationDuration = (Math.random() * 2 + 1) + 's';
body.appendChild(star);
}
for (let i = 0; i < 100; i++) {
createStar();
}
</script>
</body>
</html>