圣诞树代码复制html
时间: 2023-12-26 12:06:21 浏览: 72
html实现圣诞树代码
以下是一个简单的圣诞树代码的HTML源码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>Christmas Tree</title>
<style>
body {
background-color: #000;
}
.tree {
color: #0f0;
font-size: 1.5em;
text-align: center;
margin-top: 100px;
}
.tree:before {
content: "";
position: absolute;
top: -20px;
left: 50%;
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 40px solid #0f0;
transform: translateX(-50%);
}
.tree .layer {
position: relative;
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.tree .layer .block {
width: 40px;
height: 40px;
background-color: #0f0;
}
.tree .layer .block:nth-child(2) {
margin: 0 auto;
}
.tree .layer .block:nth-child(3) {
margin-left: auto;
}
.tree .layer .block:nth-child(4) {
margin-right: auto;
}
</style>
</head>
<body>
<div class="tree">
<div class="layer">
<div class="block"></div>
</div>
<div class="layer">
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</div>
<div class="layer">
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</div>
<div class="layer">
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</div>
</div>
</body>
</html>
```
你可以将上述代码复制到一个HTML文件中,然后在浏览器中打开该文件,即可看到一个简单的圣诞树效果。
阅读全文