3d旋转爱心粒子代码html+css
时间: 2023-12-04 15:41:45 浏览: 710
3_爱心代码.html
以下是一段HTML5和CSS3制作的3D旋转爱心粒子代码,你可以将其复制到HTML文件中并在浏览器中查看效果:
```html
<!DOCTYPE html>
<html>
<head>
<title>3D旋转爱心粒子代码</title>
<style>
body {
background-color: #000;
overflow: hidden;
}
.heart {
position: absolute;
top: 50%;
left: 50%;
transform-style: preserve-3d;
animation: rotate 10s linear infinite;
}
.heart .heart-piece {
position: absolute;
width: 100px;
height: 100px;
background-color: #f00;
border-radius: 50%;
transform-style: preserve-3d; animation: rotate 10s linear infinite;
}
.heart .heart-piece:before,
.heart .heart-piece:after {
content: "";
position: absolute;
width: 100px;
height: 100px;
background-color: #f00;
border-radius: 50%;
transform-style: preserve-3d;
animation: rotate 10s linear infinite;
}
.heart .heart-piece:before {
transform: rotateY(90deg) rotateZ(45deg);
}
.heart .heart-piece:after {
transform: rotateY(90deg) rotateZ(-45deg);
}
.heart .heart-piece:nth-child(1) {
transform: rotateY(0deg) translateZ(50px);
}
.heart .heart-piece:nth-child(2) {
transform: rotateY(90deg) translateZ(50px);
}
.heart .heart-piece:nth-child(3) {
transform: rotateY(180deg) translateZ(50px);
}
.heart .heart-piece:nth-child(4) {
transform: rotateY(-90deg) translateZ(50px);
}
@keyframes rotate {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div class="heart">
<div class="heart-piece"></div>
<div class="heart-piece"></div>
<div class="heart-piece"></div>
<div class="heart-piece"></div>
</div>
</body>
</html>
```
阅读全文