<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3水滴滴落消除特效</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
overflow: hidden;
font-family: 'Arial', sans-serif;
}
.container {
position: relative;
width: 100%;
height: 100%;
}
.drop {
position: absolute;
width: 20px;
height: 20px;
background: rgba(255, 255, 255, 0.8);
border-radius: 50%;
animation: drop 3s ease-in infinite;
box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.5);
opacity: 0;
}
.ripple {
position: absolute;
width: 20px;
height: 20px;
border: 2px solid rgba(255, 255, 255, 0.8);
border-radius: 50%;
animation: ripple 2s ease-out infinite;
opacity: 0;
}
@keyframes drop {
0% {
transform: translateY(-100px) scale(0.5);
opacity: 0;
}
10% {
opacity: 1;
}
70% {
opacity: 1;
}
80% {
transform: translateY(calc(100vh - 100px)) scale(0.5);
opacity: 0;
}
100% {
transform: translateY(calc(100vh - 80px)) scale(0.3);
opacity: 0;
}
}
@keyframes ripple {
0% {
transform: scale(0.3);
opacity: 1;
}
100% {
transform: scale(10);
opacity: 0;
}
}
.footer {
position: fixed;
bottom: 20px;
color: rgba(255, 255, 255, 0.7);
text-align: center;
width: 100%;
font-size: 14px;
z-index: 100;
}
.footer a {
color: white;
text-decoration: none;
font-weight: bold;
transition: text-shadow 0.3s;
}
.footer a:hover {
text-shadow: 0 0 10px white;
}
.title {
position: fixed;
top: 20px;
color: white;
font-size: 2.5rem;
text-align: center;
width: 100%;
text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
z-index: 100;
}
</style>
</head>
<body>
<div class="title">水滴滴落特效</div>
<div class="container" id="container">
<!-- 水滴将通过JavaScript动态添加 -->
</div>
<script>
// 创建水滴元素
const container = document.getElementById('container');
const colors = ['rgba(255,255,255,0.8)', 'rgba(173, 216, 230, 0.8)', 'rgba(135, 206, 250, 0.8)'];
function createDrop() {
// 创建水滴
const drop = document.createElement('div');
drop.className = 'drop';
// 随机位置
const left = Math.random() * 100;
drop.style.left = `${left}%`;
// 随机延迟
const delay = Math.random() * 5;
drop.style.animationDelay = `${delay}s`;
// 随机大小
const size = 0.3 + Math.random() * 0.7;
drop.style.transform = `scale(${size})`;
// 随机颜色
const color = colors[Math.floor(Math.random() * colors.length)];
drop.style.background = color;
drop.style.boxShadow = `0 0 10px 2px ${color.replace('0.8', '0.5')}`;
container.appendChild(drop);
// 创建涟漪效果
setTimeout(() => {
const ripple = document.createElement('div');
ripple.className = 'ripple';
ripple.style.left = `${left}%`;
ripple.style.bottom = '20px';
ripple.style.borderColor = color;
container.appendChild(ripple);
// 移除元素
setTimeout(() => {
ripple.remove();
}, 2000);
}, 3000 - delay * 1000);
// 移除水滴
setTimeout(() => {
drop.remove();
}, 5000);
}
// 初始创建水滴
for (let i = 0; i < 20; i++) {
setTimeout(createDrop, i * 300);
}
// 持续创建水滴
setInterval(createDrop, 500);
</script>
</body>
</html>
1599

被折叠的 条评论
为什么被折叠?



