{"id":22,"date":"2025-11-20T16:37:25","date_gmt":"2025-11-20T08:37:25","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=22"},"modified":"2025-11-20T16:37:25","modified_gmt":"2025-11-20T08:37:25","slug":"%e5%9c%a3%e8%af%9e%e8%8a%82%e5%88%b6%e4%bd%9c%e4%b8%80%e9%a2%97html%e7%9a%84%e5%9c%a3%e8%af%9e%e6%a0%91","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/20\/%e5%9c%a3%e8%af%9e%e8%8a%82%e5%88%b6%e4%bd%9c%e4%b8%80%e9%a2%97html%e7%9a%84%e5%9c%a3%e8%af%9e%e6%a0%91\/","title":{"rendered":"\u5723\u8bde\u8282\u5236\u4f5c\u4e00\u9897HTML\u7684\u5723\u8bde\u6811"},"content":{"rendered":"\n<p>\u4e3a\u4e86\u5728 HTML \u4e2d\u5236\u4f5c\u4e00\u9897\u7b80\u5355\u7684\u5723\u8bde\u6811\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 HTML \u548c CSS \u521b\u5efa\u4e00\u4e2a\u6709\u5c42\u6b21\u611f\u7684\u5723\u8bde\u6811\u5f62\u72b6\uff0c\u7ed3\u5408\u4e00\u4e9b\u57fa\u672c\u7684 CSS \u6837\u5f0f\u6765\u88c5\u9970\u5b83\u3002\u4e3a\u4e86\u589e\u52a0\u8282\u65e5\u6c1b\u56f4\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u52a0\u4e0a\u5f69\u7403\u3001\u661f\u661f\u7b49\u88c5\u9970\u5143\u7d20\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5723\u8bde\u6811\u5b9e\u73b0\u793a\u4f8b\uff0c\u4f7f\u7528 HTML \u548c CSS\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\u4ee3\u7801\uff1a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">HTML:<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;!DOCTYPE html&gt;\n&amp;lt;html lang=&quot;en&quot;&gt;\n&amp;lt;head&gt;\n    &amp;lt;meta charset=&quot;UTF-8&quot;&gt;\n    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &amp;lt;title&gt;\u5723\u8bde\u6811&amp;lt;\/title&gt;\n    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;\n&amp;lt;\/head&gt;\n&amp;lt;body&gt;\n\n    &amp;lt;div class=&quot;christmas-tree&quot;&gt;\n        &amp;lt;div class=&quot;tree-top&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;tree-layer layer-1&quot;&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;tree-layer layer-2&quot;&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;tree-layer layer-3&quot;&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;tree-layer layer-4&quot;&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;ornament&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;tree-trunk&quot;&gt;&amp;lt;\/div&gt;\n        &amp;lt;div class=&quot;star&quot;&gt;&amp;lt;\/div&gt;\n    &amp;lt;\/div&gt;\n\n&amp;lt;\/body&gt;\n&amp;lt;\/html&gt;\n\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">CSS (styles.css):<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n* {\n    margin: 0;\n    padding: 0;\n    box-sizing: border-box;\n}\n\nbody {\n    background-color: #f0f8ff;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    height: 100vh;\n    font-family: Arial, sans-serif;\n}\n\n.christmas-tree {\n    position: relative;\n    width: 200px;\n    height: 300px;\n}\n\n.tree-top {\n    position: absolute;\n    top: 0;\n    left: 50%;\n    transform: translateX(-50%);\n    width: 0;\n    height: 0;\n    border-left: 50px solid transparent;\n    border-right: 50px solid transparent;\n    border-bottom: 70px solid #228B22;\n}\n\n.tree-layer {\n    position: absolute;\n    left: 50%;\n    transform: translateX(-50%);\n    display: flex;\n    justify-content: space-around;\n}\n\n.layer-1 {\n    top: 70px;\n    width: 180px;\n}\n\n.layer-2 {\n    top: 130px;\n    width: 160px;\n}\n\n.layer-3 {\n    top: 190px;\n    width: 140px;\n}\n\n.layer-4 {\n    top: 250px;\n    width: 120px;\n}\n\n.ornament {\n    width: 15px;\n    height: 15px;\n    background-color: red;\n    border-radius: 50%;\n    margin: 10px;\n}\n\n.tree-trunk {\n    position: absolute;\n    bottom: 0;\n    left: 50%;\n    transform: translateX(-50%);\n    width: 40px;\n    height: 50px;\n    background-color: #8B4513;\n    border-radius: 5px;\n}\n\n.star {\n    position: absolute;\n    top: -30px;\n    left: 50%;\n    transform: translateX(-50%);\n    width: 0;\n    height: 0;\n    border-left: 15px solid transparent;\n    border-right: 15px solid transparent;\n    border-bottom: 30px solid yellow;\n    box-shadow: 0 0 20px 5px yellow;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>HTML \u7ed3\u6784<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>.christmas-tree<\/code>\u00a0\u662f\u6574\u4e2a\u5723\u8bde\u6811\u7684\u5bb9\u5668\u3002<\/li>\n\n\n\n<li><code>.tree-top<\/code>\u00a0\u662f\u6811\u9876\u7684\u90e8\u5206\uff0c\u7528\u900f\u660e\u7684\u8fb9\u6846\u548c\u7eff\u8272\u7684\u5e95\u8fb9\u5b9e\u73b0\u4e86\u5723\u8bde\u6811\u7684\u9876\u90e8\u5c16\u89d2\u3002<\/li>\n\n\n\n<li><code>.tree-layer<\/code>\u00a0\u662f\u6811\u7684\u5404\u4e2a\u5c42\u6b21\uff0c\u6bcf\u4e00\u5c42\u4f7f\u7528\u00a0<code>div<\/code>\u00a0\u6765\u521b\u5efa\u4e0d\u540c\u5bbd\u5ea6\u7684\u6811\u679d\u5c42\u3002<\/li>\n\n\n\n<li><code>.ornament<\/code>\u00a0\u662f\u88c5\u9970\u54c1\uff08\u5f69\u7403\uff09\uff0c\u4f7f\u7528\u7ea2\u8272\u5706\u5f62\u00a0<code>div<\/code>\u00a0\u6765\u6a21\u62df\u5f69\u7403\u3002<\/li>\n\n\n\n<li><code>.tree-trunk<\/code>\u00a0\u662f\u6811\u5e72\uff0c\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u77e9\u5f62\u6765\u8868\u793a\u3002<\/li>\n\n\n\n<li><code>.star<\/code>\u00a0\u662f\u6811\u9876\u7684\u661f\u661f\uff0c\u4f7f\u7528 CSS \u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u4e94\u89d2\u661f\u5f62\u72b6\uff0c\u5e76\u4e14\u901a\u8fc7\u00a0<code>box-shadow<\/code>\u00a0\u6dfb\u52a0\u4e86\u5149\u8f89\u6548\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>CSS \u6837\u5f0f<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u00a0<code>position: absolute;<\/code>\u00a0\u6765\u5b9a\u4f4d\u6bcf\u4e00\u5c42\u6811\u679d\u548c\u6811\u5e72\uff0c\u4f7f\u5b83\u4eec\u51c6\u786e\u5730\u53e0\u52a0\u5728\u4e00\u8d77\u3002<\/li>\n\n\n\n<li>\u6811\u9876\u7684\u90e8\u5206\uff08<code>.tree-top<\/code>\uff09\u662f\u901a\u8fc7 CSS \u7684\u00a0<code>border<\/code>\u00a0\u5c5e\u6027\u6765\u5b9e\u73b0\u7684\uff0c\u8fd9\u79cd\u65b9\u6cd5\u5141\u8bb8\u6211\u4eec\u7528\u7b80\u5355\u7684\u4ee3\u7801\u521b\u5efa\u4e09\u89d2\u5f62\u3002<\/li>\n\n\n\n<li>\u5f69\u7403\uff08<code>.ornament<\/code>\uff09\u662f\u901a\u8fc7\u00a0<code>border-radius<\/code>\u00a0\u5c5e\u6027\u5c06\u00a0<code>div<\/code>\u00a0\u8f6c\u6362\u4e3a\u5706\u5f62\uff0c\u5e76\u4f7f\u7528\u00a0<code>background-color<\/code>\u00a0\u6765\u7740\u8272\u3002<\/li>\n\n\n\n<li>\u6811\u5e72\uff08<code>.tree-trunk<\/code>\uff09\u901a\u8fc7\u77e9\u5f62\u548c\u80cc\u666f\u8272\u6765\u8868\u793a\u3002<\/li>\n\n\n\n<li>\u6811\u9876\u7684\u661f\u661f\u662f\u901a\u8fc7\u00a0<code>border<\/code>\u00a0\u548c\u00a0<code>box-shadow<\/code>\u00a0\u521b\u5efa\u7684\u4e94\u89d2\u661f\uff0c\u589e\u5f3a\u4e86\u661f\u661f\u7684\u53d1\u5149\u6548\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u6548\u679c\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fd9\u4e2a\u793a\u4f8b\u5c55\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u5723\u8bde\u6811\uff0c\u5305\u542b\u4e86\u4e0d\u540c\u5c42\u7ea7\u7684\u7eff\u8272\u6811\u679d\u3001\u5f69\u7403\u88c5\u9970\u3001\u6811\u5e72\u548c\u95ea\u4eae\u7684\u661f\u661f\u3002<\/li>\n\n\n\n<li>\u80cc\u666f\u4e3a\u6de1\u84dd\u8272\uff0c\u589e\u52a0\u4e86\u8282\u65e5\u7684\u6c1b\u56f4\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u53ef\u6269\u5c55\u6027\uff1a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u66f4\u591a\u88c5\u9970<\/strong>\uff1a\u4f60\u53ef\u4ee5\u4e3a\u6811\u6dfb\u52a0\u66f4\u591a\u7684\u88c5\u9970\u54c1\uff0c\u6bd4\u5982\u4f7f\u7528\u4e0d\u540c\u989c\u8272\u7684\u5706\u7403\uff0c\u6216\u8005\u52a0\u5165\u706f\u5149\u6548\u679c\u3002<\/li>\n\n\n\n<li><strong>\u52a8\u753b\u6548\u679c<\/strong>\uff1a\u53ef\u4ee5\u4e3a\u6811\u6dfb\u52a0\u52a8\u753b\u6548\u679c\uff0c\u4f8b\u5982\u95ea\u70c1\u7684\u661f\u661f\uff0c\u6216\u8005\u65cb\u8f6c\u7684\u6811\u679d\u3002<\/li>\n\n\n\n<li><strong>\u54cd\u5e94\u5f0f<\/strong>\uff1a\u4f7f\u7528\u5a92\u4f53\u67e5\u8be2\uff08<code>@media<\/code>\uff09\u4f7f\u5f97\u5723\u8bde\u6811\u5728\u4e0d\u540c\u5c4f\u5e55\u5c3a\u5bf8\u4e0b\u81ea\u9002\u5e94\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528 HTML \u548c CSS \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u53c8\u6709\u8da3\u7684\u5723\u8bde\u6811\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u66f4\u591a\u81ea\u5b9a\u4e49\u548c\u4f18\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4e86\u5728 HTML \u4e2d\u5236\u4f5c\u4e00\u9897\u7b80\u5355\u7684\u5723\u8bde\u6811\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 HTML \u548c CSS \u521b&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/20\/%e5%9c%a3%e8%af%9e%e8%8a%82%e5%88%b6%e4%bd%9c%e4%b8%80%e9%a2%97html%e7%9a%84%e5%9c%a3%e8%af%9e%e6%a0%91\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-html-xhtml"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions\/23"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}