html花瓣飘落代码
时间: 2023-11-14 07:07:32 浏览: 67
以下是一个简单的 HTML 花瓣飘落代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>花瓣飘落效果</title>
<style>
body {
background-color: #f5f5f5;
overflow: hidden;
}
.petal {
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #ff69b4;
box-shadow: 0 0 10px #ff69b4;
animation: fall 5s linear infinite;
}
@keyframes fall {
from {
transform: translate(0, -100%);
}
to {
transform: translate(100vw, 100vh);
}
}
</style>
</head>
<body>
<script>
for (var i = 0; i < 50; i++) {
var petal = document.createElement("div");
petal.className = "petal";
petal.style.left = Math.random() * window.innerWidth + "px";
petal.style.animationDelay = Math.random() * 5 + "s";
document.body.appendChild(petal);
}
</script>
</body>
</html>
```