生成一个飘落樱花的html代码
时间: 2023-04-02 22:01:05 浏览: 279
以下是生成飘落樱花的 HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>飘落樱花</title>
<style>
body {
background-color: #F5F5F5;
overflow: hidden;
}
.sakura {
position: absolute;
background-image: url('https://i.imgur.com/7bMqO2M.png');
background-size: contain;
width: 20px;
height: 20px;
animation: sakura-fall 10s linear infinite;
}
@keyframes sakura-fall {
% {
transform: translate(, -10%);
opacity: ;
}
50% {
transform: translate(50%, 100%);
opacity: 1;
}
100% {
transform: translate(100%, 200%);
opacity: ;
}
}
</style>
</head>
<body>
<script>
for (var i = ; i < 50; i++) {
var sakura = document.createElement('div');
sakura.className = 'sakura';
sakura.style.left = Math.random() * window.innerWidth + 'px';
sakura.style.animationDelay = Math.random() * 10 + 's';
document.body.appendChild(sakura);
}
</script>
</body>
</html>
```
希望能帮到你!
阅读全文