Untitled
unknown
plain_text
a year ago
1.4 kB
7
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snowflake Effect</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
background-color: #1e1e1e;
overflow: hidden;
color: white;
}
.snowflake {
position: fixed;
top: -10px;
color: #fff;
font-size: 1em;
user-select: none;
pointer-events: none;
z-index: 9999;
animation: fall linear infinite;
}
@keyframes fall {
0% { transform: translateY(0); }
100% { transform: translateY(100vh); }
}
</style>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', function () {
const numFlakes = 50; // Number of snowflakes
const body = document.body;
for (let i = 0; i < numFlakes; i++) {
const snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflake.innerHTML = '❄';
snowflake.style.left = Math.random() * 100 + 'vw';
snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
snowflake.style.fontSize = Math.random() * 20 + 10 + 'px';
body.appendChild(snowflake);
}
});
</script>
</body>
</html>
Editor is loading...
Leave a Comment