<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>美元飘落动画特效</title>
<!-- 引入Animate.css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: #f5f5f5;
font-family: Arial, sans-serif;
height: 100vh;
position: relative;
}
.money-fall-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
}
.dollar {
position: absolute;
font-size: 24px;
color: #2ecc71;
font-weight: bold;
text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
user-select: none;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
/* 自定义下落动画 */
@keyframes falling {
0% {
transform: translateY(-100px) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(calc(100vh + 100px)) rotate(360deg);
opacity: 0;
}
}
.falling {
animation-name: falling;
}
/* 左右飘动效果 */
@keyframes sway {
0%, 100% {
transform: translateX(0);
}
50% {
transform: translateX(50px);
}
}
.sway {
animation-name: sway, falling;
animation-duration: 3s, 5s;
animation-iteration-count: infinite, infinite;
animation-timing-function: ease-in-out, linear;
}
.content {
position: relative;
z-index: 1;
text-align: center;
padding-top: 50px;
}
h1 {
color: #333;
font-size: 3em;
margin-bottom: 20px;
}
/* 插入的链接样式 */
.custom-link {
position: fixed;
bottom: 20px;
right: 20px;
color: rgba(0,0,0,0.7);
text-decoration: none;
font-size: 14px;
background: rgba(255,255,255,0.3);
padding: 8px 15px;
border-radius: 20px;
z-index: 100;
transition: all 0.3s ease;
}
.custom-link:hover {
color: black;
background: rgba(255,255,255,0.5);
}
</style>
</head>
<body>
<div class="content">
<h1 class="animate__animated animate__bounceIn">美元飘落特效</h1>
<p class="animate__animated animate__fadeIn">使用Animate.css创建的炫酷动画效果</p>
</div>
<div class="money-fall-container" id="moneyContainer"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const moneyContainer = document.getElementById('moneyContainer');
const dollarSymbols = ['$', '€', '¥', '£']; // 多种货币符号
// 创建下落美元符号
function createDollar() {
const dollar = document.createElement('div');
dollar.className = 'dollar animate__animated';
// 随机选择动画效果
const animations = ['falling', 'sway'];
const randomAnim = animations[Math.floor(Math.random() * animations.length)];
dollar.classList.add(randomAnim);
// 随机属性
dollar.textContent = dollarSymbols[Math.floor(Math.random() * dollarSymbols.length)];
dollar.style.left = Math.random() * 100 + 'vw';
dollar.style.fontSize = (Math.random() * 20 + 16) + 'px';
dollar.style.animationDuration = (Math.random() * 3 + 3) + 's';
dollar.style.animationDelay = Math.random() * 2 + 's';
// 随机颜色 - 绿色系
const greenShade = Math.floor(Math.random() * 100 + 100);
dollar.style.color = `rgb(50, ${greenShade}, 50)`;
moneyContainer.appendChild(dollar);
// 动画结束后移除元素
dollar.addEventListener('animationend', function() {
dollar.remove();
});
}
// 初始创建一批美元符号
for (let i = 0; i < 30; i++) {
setTimeout(createDollar, i * 300);
}
// 持续创建新美元符号
setInterval(createDollar, 300);
// 点击页面添加更多美元符号
document.addEventListener('click', function() {
for (let i = 0; i < 10; i++) {
setTimeout(createDollar, i * 100);
}
});
});
</script>
</body>
</html>
634

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



