html圣诞树编程代码
时间: 2023-12-11 19:32:53 浏览: 103
html实现圣诞树代码
以下是一个简单的HTML圣诞树代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>Christmas Tree</title>
<style>
body {
background-color: #1a1a1a;
}
.tree {
position: relative;
margin: 0 auto;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid green;
}
.star {
position: absolute;
top: -30px;
left: 25px;
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid yellow;
transform: rotate(45deg);
}
.light {
position: absolute;
background-color: yellow;
width: 20px;
height: 20px;
border-radius: 50%;
animation: blink 1s infinite;
}
.light1 {
top: 60px;
left: 45px;
}
.light2 {
top: 80px;
left: 25px;
}
.light3 {
top: 100px;
left: 60px;
}
@keyframes blink {
0% {
opacity: 0.2;
}
20% {
opacity: 1;
}
100% {
opacity: 0.2;
}
}
</style>
</head>
<body>
<div class="tree">
<div class="star"></div>
</div>
<div class="light light1"></div>
<div class="light light2"></div>
<div class="light light3"></div>
</body>
</html>
```
阅读全文