下粉红色love雨的代码html
时间: 2023-06-30 14:17:47 浏览: 46
好的,以下是一个粉红色love雨的代码HTML示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>粉色Love雨代码</title>
<style>
body {
background-color: black;
overflow: hidden;
}
.heart {
position: absolute;
display: block;
background-color: pink;
height: 30px;
width: 30px;
margin-left: -15px;
margin-top: -15px;
animation: love 1.5s ease-out;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
left: 15px;
top: 0;
width: 15px;
height: 30px;
background-color: pink;
border-radius: 15px 15px 0 0;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.heart:after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
}
@keyframes love {
0% {
transform: translateY(0);
}
100% {
transform: translateY(800px) rotate(360deg);
}
}
</style>
</head>
<body>
<script>
function createHeart() {
const heart = document.createElement("div");
heart.classList.add("heart");
heart.style.left = Math.random() * 100 + "%";
heart.style.animationDelay = Math.random() + "s";
document.body.appendChild(heart);
setTimeout(() => {
heart.remove();
}, 2000);
}
setInterval(createHeart, 100);
</script>
</body>
</html>
```
您可以将代码复制到HTML文件中并在浏览器上运行,就可以看到粉红色的Love雨效果。每隔100毫秒会在页面上创建一个Love图案,它会从页面顶部下落到底部并旋转。
相关推荐
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)