帮我生成一个飘落樱花的html可运行的代码
时间: 2023-04-02 22:01:07 浏览: 139
Python+樱花飘落+源代码
5星 · 资源好评率100%
好的,以下是生成飘落樱花的 HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>飘落樱花</title>
<style>
body {
background-color: #F5F5F5;
overflow: hidden;
}
.sakura {
position: absolute;
display: block;
background-image: url('https://cdn.jsdelivr.net/gh/lingxiao-Zhu/CDN/img/sakura.png');
background-size: contain;
background-repeat: no-repeat;
animation: sakura-fall 10s linear infinite;
z-index: 9999;
}
@keyframes sakura-fall {
% {
transform: translate(, -10%);
}
100% {
transform: translate(100vw, 110vh);
}
}
</style>
</head>
<body>
<script>
for (var i = ; i < 50; i++) {
createSakura();
}
function createSakura() {
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>
```
希望能帮到你!
阅读全文