3d圣诞树html代码
时间: 2023-12-21 12:32:00 浏览: 121
桌面圣诞树合集.rar
以下是一个使用HTML和CSS创建的3D圣诞树的代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<style>
.tree {
position: relative;
width: 0;
height: 0;
margin: 0 auto;
border-left: 250px solid transparent;
border-right: 250px solid transparent;
border-bottom: 500px solid green;
}
.tree::before {
content: "";
position: absolute;
top: -250px;
left: 0;
width: 0;
height: 0;
border-left: 200px solid transparent;
border-right: 200px solid transparent;
border-bottom: 400px solid green;
}
.tree::after {
content: "";
position: absolute;
top: -400px;
left: 0;
width: 0;
height: 0;
border-left: 150px solid transparent;
border-right: 150px solid transparent;
border-bottom: 300px solid green;
}
.trunk {
position: absolute;
bottom: 0;
left: 175px;
width: 50px;
height: 100px;
background-color: brown;
animation: rotate 4s infinite linear;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="tree"></div>
<div class="trunk"></div>
</body>
</html>
```
这段代码会创建一个500x500像素的3D圣诞树,树干是棕色的,树枝是绿色的。树干和树枝会不断旋转360度,形成动画效果。
阅读全文