圣诞树html动态代码
时间: 2023-12-09 22:36:57 浏览: 192
以下是一个简单的圣诞树HTML动态代码的例子:
```html
<!DOCTYPE html>
<html>
<head>
<title>Christmas Tree</title>
<style body {
background-color: #000;
}
.tree {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 200px;
height: 200px;
background-color: #006400;
border-radius: 0 0 50% 50%;
overflow: hidden;
}
.tree:before {
content: "";
position: absolute;
top: -50%;
left: 0;
width: 200px;
height: 200px;
background-color: #006400;
border-radius: 50%;
}
.tree:after {
content: "";
position: absolute;
top: 50%;
left: -50%;
width: 200px;
height: 200px;
background-color: #006400; border-radius: 50%;
}
.tree div {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 20px;
height: 40px;
background-color: #8B0000;
border-radius: 0 0 10px 10px;
animation: lights 1s infinite;
}
.tree div:nth-child(1) {
transform: translate(-50%, -50%) rotate(30deg);
}
.tree div:nth-child(2) {
transform: translate(-50%, -50%) rotate(60deg);
}
.tree div:nth-child(3) {
transform: translate(-50%, -50%) rotate(90deg);
}
.tree div:nth-child(4) {
transform: translate(-50%, -50%) rotate(120deg);
}
.tree div:nth-child(5) {
transform: translate(-50%, -50%) rotate(150deg);
}
@keyframes lights {
0% {
box-shadow: 0 0 10px #FFF, 0 0 20px #FFF, 0 0 30px #FFF, 0 0 40px #FFF, 0 0 50px #FFF, 0 0 60px #FFF, 0 0 70px #FFF;
}
50% {
box-shadow: 0 0 20px #FFF, 0 0 30px #FFF, 0 0 40px #FFF, 0 0 50px #FFF, 0 0 60px #FFF, 0 0 70px #FFF, 0 0 80px #FFF;
}
100% {
box-shadow: 0 0 10px #FFF, 0 0 20px #FFF, 0 0 30px #FFF, 0 0 40px #FFF, 0 0 50px #FFF, 0 0 60px #FFF, 0 0 70px #FFF;
}
}
</style>
</head>
<body>
<div class="tree">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
```
阅读全文