HTML:实现圣诞树代码
以下是一个用HTML实现圣诞树的示例代码:
<!DOCTYPE html> <html> <head> <style> body { background-color: #333; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .tree { color: green; text-align: center; font-size: 20px; line-height: 20px; margin: 0 auto; } .tree-top { color: brown; font-size: 40px; line-height: 40px; margin-bottom: -10px; } .tree-body { height: 300px; position: relative; } .tree-layer { position: absolute; left: 0; right: 0; bottom: 0; } .tree-layer:nth-child(1) { height: 40px; background-color: green; } .tree-layer:nth-child(2) { height: 60px; background-color: limegreen; margin-bottom:
复制