html圣诞树代码动态
时间: 2023-12-14 09:34:01 浏览: 169
以下是一个简单的HTML圣诞树代码,它使用CSS和JavaScript来实现动态效果:
```html
<!DOCTYPE html>
<html>
<head>
<title>Christmas Tree</title>
<style>
body {
background-color: #111;
}
.tree {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 200px;
height: 300px;
background-color: #0B6623;
border-radius: 0 0 10px 10px;
overflow: hidden;
}
.tree:before {
content: "";
position: absolute;
top: -50px;
left: -50px;
width: 300px;
height: 300px;
background-color: #0B6623;
border-radius: 50%;
}
.tree:after {
content: "";
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid #006400;
}
.tree ul {
position: absolute;
top: 100px;
left: 50%;
transform: translateX(-50%);
margin: 0;
padding: 0;
list-style: none;
}
.tree ul li {
position: relative;
margin: 0 5px;
padding: 0;
width: 20px;
height: 30px;
background-color: #006400;
border-radius: 0 0 5px 5px;
}
.tree ul li:before {
content: "";
position: absolute;
top: -15px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 15px solid #006400;
}
.tree ul li:after {
content: "";
position: absolute;
bottom: -15px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 15px solid #006400;
}
.tree ul li:nth-child(1) {
background-color: #FFD700;
}
.tree ul li:nth-child(2) {
background-color: #FFA500;
}
.tree ul li:nth-child(3) {
background-color: #FFD700;
}
.tree ul li:nth-child(4) {
background-color: #FFA500;
}
.tree ul li:nth-child(5) {
background-color: #FFD700;
}
.tree ul li:nth-child(6) {
background-color: #FFA500;
}
.tree ul li:nth-child(7) {
background-color: #FFD700;
}
.tree ul li:nth-child(8) {
background-color: #FFA500;
}
.tree ul li:nth-child(9) {
background-color: #FFD700;
}
.tree ul li:nth-child(10) {
background-color: #FFA500;
}
.tree ul li:nth-child(11) {
background-color: #FFD700;
}
.tree ul li:nth-child(12) {
background-color: #FFA500;
}
.tree ul li:nth-child(13) {
background-color: #FFD700;
}
.tree ul li:nth-child(14) {
background-color: #FFA500;
}
.tree ul li:nth-child(15) {
background-color: #FFD700;
}
.tree ul li:nth-child(16) {
background-color: #FFA500;
}
.tree ul li:nth-child(17) {
background-color: #FFD700;
}
.tree ul li:nth-child(18) {
background-color: #FFA500;
}
.tree ul li:nth-child(19) {
background-color: #FFD700;
}
.tree ul li:nth-child(20) {
background-color: #FFA500;
}
.tree ul li:nth-child(21) {
background-color: #FFD700;
}
.tree ul li:nth-child(22) {
background-color: #FFA500;
}
.tree ul li:nth-child(23) {
background-color: #FFD700;
}
.tree ul li:nth-child(24) {
background-color: #FFA500;
}
.tree ul li:nth-child(25) {
background-color: #FFD700;
}
.tree ul li:nth-child(26) {
background-color: #FFA500;
}
.tree ul li:nth-child(27) {
background-color: #FFD700;
}
.tree ul li:nth-child(28) {
background-color: #FFA500;
}
.tree ul li:nth-child(29) {
background-color: #FFD700;
}
.tree ul li:nth-child(30) {
background-color: #FFA500;
}
.tree ul li:nth-child(31) {
background-color: #FFD700;
}
.tree ul li:nth-child(32) {
background-color: #FFA500;
}
.tree ul li:nth-child(33) {
background-color: #FFD700;
}
.tree ul li:nth-child(34) {
background-color: #FFA500;
}
.tree ul li:nth-child(35) {
background-color: #FFD700;
}
.tree ul li:nth-child(36) {
background-color: #FFA500;
}
.tree ul li:nth-child(37) {
background-color: #FFD700;
}
.tree ul li:nth-child(38) {
background-color: #FFA500;
}
.tree ul li:nth-child(39) {
background-color: #FFD700;
}
.tree ul li:nth-child(40) {
background-color: #FFA500;
}
.tree ul li:nth-child(41) {
background-color: #FFD700;
}
.tree ul li:nth-child(42) {
background-color: #FFA500;
阅读全文