<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Floating Lanterns Animation</title>
<style>
/* General Reset */
body, html {
margin: 0;
padding: 0;
overflow: hidden;
background: linear-gradient(to bottom, #000428, #004e92);
height: 100vh;
}
/* Night Sky Background */
.sky {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}
/* Floating Lanterns */
.lantern {
position: absolute;
bottom: -100px;
width: 40px;
height: 60px;
background: radial-gradient(circle, #ffcc70, #d38e38);
border-radius: 10px;
box-shadow: 0 0 20px 5px rgba(255, 204, 112, 0.8);
animation: floatUp 8s infinite ease-in;
opacity: 0.8;
}
/* Flickering Effect */
@keyframes floatUp {
0% {
transform: translateY(0) translateX(0);
opacity: 0.8;
}
50% {
transform: translateY(-50vh) translateX(10px);
opacity: 0.9;
}
100% {
transform: translateY(-100vh) translateX(-10px);
opacity: 0;
}
}
/* Star Effect */
.star {
position: absolute;
background: white;
width: 2px;
height: 2px;
border-radius: 50%;
box-shadow: 0 0 8px white;
animation: twinkle 3s infinite;
}
@keyframes twinkle {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
/* Shooting Star Effect */
.shooting-star {
position: absolute;
width: 100px;
height: 2px;
background: linear-gradient(90deg, white, transparent);
opacity: 0.7;
animation: shootingStar 3s infinite ease-in-out;
}
@keyframes shootingStar {
0% {
transform: translate(-50vw, -50vh) rotate(45deg);
opacity: 1;
}
100% {
transform: translate(50vw, 50vh) rotate(45deg);
opacity: 0;
}
}
/* Interactive Click Message */
.click-message {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
color: #fff;
font-size: 1.2rem;
background: rgba(0, 0, 0, 0.5);
padding: 5px 15px;
border-radius: 5px;
animation: fadeInOut 3s infinite;
}
@keyframes fadeInOut {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
</style>
</head>
<body>
<div class="sky" id="sky"></div>
<!-- <div class="click-message">Click anywhere to release more lanterns!</div> -->
<script>
// Generate Random Lanterns
function createLantern() {
const lantern = document.createElement('div');
lantern.classList.add('lantern');
lantern.style.left = `${Math.random() * 100}vw`;
lantern.style.animationDuration = `${5 + Math.random() * 5}s`;
document.getElementById('sky').appendChild(lantern);
// Remove after animation
setTimeout(() => {
lantern.remove();
}, 10000);
}
// Generate Random Stars
function createStar() {
const star = document.createElement('div');
star.classList.add('star');
star.style.left = `${Math.random() * 100}vw`;
star.style.top = `${Math.random() * 100}vh`;
star.style.animationDuration = `${1 + Math.random()}s`;
document.getElementById('sky').appendChild(star);
}
// Generate Shooting Stars
function createShootingStar() {
const shootingStar = document.createElement('div');
shootingStar.classList.add('shooting-star');
shootingStar.style.top = `${Math.random() * 100}vh`;
shootingStar.style.left = `${Math.random() * 100}vw`;
document.getElementById('sky').appendChild(shootingStar);
setTimeout(() => {
shootingStar.remove();
}, 3000);
}
setInterval(createLantern, 500);
setInterval(createShootingStar, 2000);
for (let i = 0; i < 50; i++) {
createStar();
}
document.getElementById('sky').addEventListener('click', (e) => {
const lantern = document.createElement('div');
lantern.classList.add('lantern');
lantern.style.left = `${e.clientX}px`;
lantern.style.bottom = `0`;
document.getElementById('sky').appendChild(lantern);
setTimeout(() => {
lantern.remove();
}, 10000);
});
</script>
</body>
</html>
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)