{"id":51,"date":"2025-11-20T16:50:16","date_gmt":"2025-11-20T08:50:16","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=51"},"modified":"2025-11-20T16:50:16","modified_gmt":"2025-11-20T08:50:16","slug":"html%e5%ae%9e%e7%8e%b0%e4%bb%bfwindows%e6%a1%8c%e9%9d%a2%e4%b8%bb%e9%a2%98%e7%89%b9%e6%95%88%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/20\/html%e5%ae%9e%e7%8e%b0%e4%bb%bfwindows%e6%a1%8c%e9%9d%a2%e4%b8%bb%e9%a2%98%e7%89%b9%e6%95%88%e7%9a%84%e5%ae%9e%e7%8e%b0\/","title":{"rendered":"HTML\u5b9e\u73b0\u4effWindows\u684c\u9762\u4e3b\u9898\u7279\u6548\u7684\u5b9e\u73b0"},"content":{"rendered":"\n<p>\u5728 HTML \u548c CSS \u4e2d\u5b9e\u73b0\u4eff Windows \u684c\u9762\u4e3b\u9898\u7279\u6548\uff0c\u901a\u5e38\u4f1a\u6d89\u53ca\u5230\u591a\u4e2a\u65b9\u9762\uff0c\u5305\u62ec\u7a97\u53e3\u754c\u9762\u7684\u521b\u5efa\u3001\u62d6\u52a8\u3001\u6700\u5c0f\u5316\u3001\u6700\u5927\u5316\u3001\u5173\u95ed\u6309\u94ae\u7684\u8bbe\u8ba1\u3001\u4ee5\u53ca\u80cc\u666f\u548c\u7a97\u53e3\u7684\u5c42\u7ea7\u63a7\u5236\u7b49\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 HTML5 \u548c CSS3 \u7684\u4e00\u4e9b\u7279\u6027\u6765\u6a21\u62df\u4e00\u4e2a\u57fa\u672c\u7684\u684c\u9762\u754c\u9762\uff0c\u540c\u65f6\u4f7f\u7528 JavaScript \u6765\u5b9e\u73b0\u62d6\u52a8\u3001\u6700\u5c0f\u5316\u7b49\u4ea4\u4e92\u6548\u679c\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u73b0\u793a\u4f8b\uff0c\u6a21\u62df Windows \u684c\u9762\u754c\u9762\u7684\u7a97\u53e3\u6548\u679c\uff0c\u5305\u62ec\u51e0\u4e2a\u529f\u80fd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7a97\u53e3\u521b\u5efa\u4e0e\u5173\u95ed<\/strong><\/li>\n\n\n\n<li><strong>\u7a97\u53e3\u62d6\u52a8\u6548\u679c<\/strong><\/li>\n\n\n\n<li><strong>\u7a97\u53e3\u6700\u5927\u5316\u4e0e\u6700\u5c0f\u5316\u6548\u679c<\/strong><\/li>\n\n\n\n<li><strong>\u57fa\u672c\u7684\u7a97\u53e3\u6837\u5f0f<\/strong><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">1. HTML \u7ed3\u6784<\/h3>\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;Windows Desktop Simulation&amp;lt;\/title&gt;\n    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;\n&amp;lt;\/head&gt;\n&amp;lt;body&gt;\n\n    &amp;lt;!-- \u684c\u9762\u80cc\u666f --&gt;\n    &amp;lt;div class=&quot;desktop&quot;&gt;\n        &amp;lt;!-- \u7a97\u53e31 --&gt;\n        &amp;lt;div class=&quot;window&quot; id=&quot;window1&quot;&gt;\n            &amp;lt;div class=&quot;window-header&quot;&gt;\n                &amp;lt;span class=&quot;window-title&quot;&gt;My Computer&amp;lt;\/span&gt;\n                &amp;lt;button class=&quot;close-btn&quot; onclick=&quot;closeWindow(&#039;window1&#039;)&quot;&gt;X&amp;lt;\/button&gt;\n                &amp;lt;button class=&quot;minimize-btn&quot; onclick=&quot;minimizeWindow(&#039;window1&#039;)&quot;&gt;_&amp;lt;\/button&gt;\n                &amp;lt;button class=&quot;maximize-btn&quot; onclick=&quot;maximizeWindow(&#039;window1&#039;)&quot;&gt;&#x5B;]&amp;lt;\/button&gt;\n            &amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;window-body&quot;&gt;\n                &amp;lt;p&gt;This is a basic simulation of a Windows desktop window. You can move, minimize, or close it.&amp;lt;\/p&gt;\n            &amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n\n        &amp;lt;!-- \u7a97\u53e32 --&gt;\n        &amp;lt;div class=&quot;window&quot; id=&quot;window2&quot;&gt;\n            &amp;lt;div class=&quot;window-header&quot;&gt;\n                &amp;lt;span class=&quot;window-title&quot;&gt;File Explorer&amp;lt;\/span&gt;\n                &amp;lt;button class=&quot;close-btn&quot; onclick=&quot;closeWindow(&#039;window2&#039;)&quot;&gt;X&amp;lt;\/button&gt;\n                &amp;lt;button class=&quot;minimize-btn&quot; onclick=&quot;minimizeWindow(&#039;window2&#039;)&quot;&gt;_&amp;lt;\/button&gt;\n                &amp;lt;button class=&quot;maximize-btn&quot; onclick=&quot;maximizeWindow(&#039;window2&#039;)&quot;&gt;&#x5B;]&amp;lt;\/button&gt;\n            &amp;lt;\/div&gt;\n            &amp;lt;div class=&quot;window-body&quot;&gt;\n                &amp;lt;p&gt;Another window simulation for file explorer.&amp;lt;\/p&gt;\n            &amp;lt;\/div&gt;\n        &amp;lt;\/div&gt;\n    &amp;lt;\/div&gt;\n\n    &amp;lt;script src=&quot;script.js&quot;&gt;&amp;lt;\/script&gt;\n&amp;lt;\/body&gt;\n&amp;lt;\/html&gt;\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">2. CSS \u6837\u5f0f<\/h3>\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: #008080;\n    font-family: Arial, sans-serif;\n}\n\n.desktop {\n    width: 100vw;\n    height: 100vh;\n    background: #2c3e50;\n    position: relative;\n}\n\n.window {\n    width: 300px;\n    height: 200px;\n    background: #f1f1f1;\n    border: 2px solid #000;\n    position: absolute;\n    top: 50px;\n    left: 50px;\n    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);\n    display: none;\n}\n\n.window-header {\n    background-color: #2980b9;\n    color: white;\n    padding: 10px;\n    display: flex;\n    justify-content: space-between;\n    cursor: move;\n}\n\n.window-title {\n    font-size: 16px;\n}\n\nbutton {\n    background: #ecf0f1;\n    border: none;\n    padding: 5px;\n    cursor: pointer;\n}\n\nbutton:hover {\n    background: #bdc3c7;\n}\n\n.window-body {\n    padding: 10px;\n}\n\nbutton.close-btn {\n    background: #e74c3c;\n    color: white;\n}\n\nbutton.minimize-btn {\n    background: #f39c12;\n    color: white;\n}\n\nbutton.maximize-btn {\n    background: #27ae60;\n    color: white;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">3. JavaScript \u4ea4\u4e92\u529f\u80fd<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u8ba9\u7a97\u53e3\u53ef\u4ee5\u88ab\u62d6\u52a8\nfunction dragElement(elmnt) {\n    var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;\n    \n    if (document.getElementById(elmnt.id + &quot;-header&quot;)) {\n        \/\/ \u5982\u679c\u5b58\u5728\u5934\u90e8\u533a\u57df\n        document.getElementById(elmnt.id + &quot;-header&quot;).onmousedown = dragMouseDown;\n    } else {\n        elmnt.onmousedown = dragMouseDown;\n    }\n\n    function dragMouseDown(e) {\n        e = e || window.event;\n        e.preventDefault();\n        \/\/ \u83b7\u53d6\u9f20\u6807\u5f53\u524d\u4f4d\u7f6e\n        pos3 = e.clientX;\n        pos4 = e.clientY;\n        document.onmouseup = closeDragElement;\n        document.onmousemove = elementDrag;\n    }\n\n    function elementDrag(e) {\n        e = e || window.event;\n        e.preventDefault();\n        \/\/ \u8ba1\u7b97\u9f20\u6807\u79fb\u52a8\u7684\u8ddd\u79bb\n        pos1 = pos3 - e.clientX;\n        pos2 = pos4 - e.clientY;\n        pos3 = e.clientX;\n        pos4 = e.clientY;\n        elmnt.style.top = (elmnt.offsetTop - pos2) + &quot;px&quot;;\n        elmnt.style.left = (elmnt.offsetLeft - pos1) + &quot;px&quot;;\n    }\n\n    function closeDragElement() {\n        document.onmouseup = null;\n        document.onmousemove = null;\n    }\n}\n\n\/\/ \u6700\u5c0f\u5316\u7a97\u53e3\nfunction minimizeWindow(windowId) {\n    var window = document.getElementById(windowId);\n    window.style.display = &#039;none&#039;;\n}\n\n\/\/ \u6700\u5927\u5316\u7a97\u53e3\nfunction maximizeWindow(windowId) {\n    var window = document.getElementById(windowId);\n    if (window.style.width === &#039;100%&#039;) {\n        window.style.width = &#039;300px&#039;;\n        window.style.height = &#039;200px&#039;;\n        window.style.top = &#039;50px&#039;;\n        window.style.left = &#039;50px&#039;;\n    } else {\n        window.style.width = &#039;100%&#039;;\n        window.style.height = &#039;100%&#039;;\n        window.style.top = &#039;0&#039;;\n        window.style.left = &#039;0&#039;;\n    }\n}\n\n\/\/ \u5173\u95ed\u7a97\u53e3\nfunction closeWindow(windowId) {\n    var window = document.getElementById(windowId);\n    window.style.display = &#039;none&#039;;\n}\n\n\/\/ \u6253\u5f00\u7a97\u53e3\nfunction openWindow(windowId) {\n    var window = document.getElementById(windowId);\n    window.style.display = &#039;block&#039;;\n}\n\n\/\/ \u521d\u59cb\u5316\u6240\u6709\u7a97\u53e3\u7684\u62d6\u52a8\u6548\u679c\ndocument.addEventListener(&quot;DOMContentLoaded&quot;, function() {\n    dragElement(document.getElementById(&quot;window1&quot;));\n    dragElement(document.getElementById(&quot;window2&quot;));\n    openWindow(&#039;window1&#039;);\n    openWindow(&#039;window2&#039;);\n});\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">4. \u89e3\u91ca\u548c\u529f\u80fd\u5b9e\u73b0<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u684c\u9762\u80cc\u666f<\/strong>\uff1a\u901a\u8fc7\u00a0<code>.desktop<\/code>\u00a0\u7c7b\u8bbe\u7f6e\u4e86\u684c\u9762\u80cc\u666f\u7684\u989c\u8272\uff0c\u6a21\u62df\u4e86\u4e00\u4e2a\u57fa\u672c\u7684\u684c\u9762\u73af\u5883\u3002<\/li>\n\n\n\n<li><strong>\u7a97\u53e3\u8bbe\u8ba1<\/strong>\uff1a\u6bcf\u4e2a\u7a97\u53e3\u662f\u4e00\u4e2a\u00a0<code>div<\/code>\u00a0\u5143\u7d20\uff0c\u5305\u542b\u6807\u9898\u680f\u3001\u6700\u5c0f\u5316\u3001\u6700\u5927\u5316\u548c\u5173\u95ed\u6309\u94ae\u3002\u6bcf\u4e2a\u7a97\u53e3\u90fd\u53ef\u4ee5\u88ab\u62d6\u52a8\uff0c\u5e76\u5177\u6709\u57fa\u672c\u7684\u63a7\u5236\u6309\u94ae\u3002<\/li>\n\n\n\n<li><strong>\u62d6\u52a8\u6548\u679c<\/strong>\uff1a\u4f7f\u7528 JavaScript \u6765\u5b9e\u73b0\u7a97\u53e3\u7684\u62d6\u52a8\u529f\u80fd\uff0c\u5229\u7528\u00a0<code>mousedown<\/code>\u00a0\u4e8b\u4ef6\u6355\u6349\u9f20\u6807\u6309\u4e0b\u5e76\u6839\u636e\u9f20\u6807\u7684\u79fb\u52a8\u8c03\u6574\u7a97\u53e3\u7684\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li><strong>\u6700\u5c0f\u5316\u548c\u6700\u5927\u5316<\/strong>\uff1a\u901a\u8fc7\u63a7\u5236\u00a0<code>window.style.display<\/code>\u00a0\u548c\u00a0<code>window.style.width<\/code>\u3001<code>window.style.height<\/code>\u00a0\u6765\u6a21\u62df\u7a97\u53e3\u7684\u6700\u5c0f\u5316\u548c\u6700\u5927\u5316\u6548\u679c\u3002<\/li>\n\n\n\n<li><strong>\u5173\u95ed\u7a97\u53e3<\/strong>\uff1a\u901a\u8fc7\u00a0<code>window.style.display = 'none'<\/code>\u00a0\u6765\u9690\u85cf\u7a97\u53e3\uff0c\u6a21\u62df\u5173\u95ed\u7a97\u53e3\u7684\u6548\u679c\u3002<\/li>\n\n\n\n<li><strong>\u6253\u5f00\u7a97\u53e3<\/strong>\uff1a\u4f7f\u7528\u00a0<code>window.style.display = 'block'<\/code>\u00a0\u6765\u663e\u793a\u9690\u85cf\u7684\u7a97\u53e3\uff0c\u6a21\u62df\u6253\u5f00\u7a97\u53e3\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u6548\u679c\u6f14\u793a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f60\u53ef\u4ee5\u62d6\u52a8\u7a97\u53e3\uff0c\u6700\u5c0f\u5316\u3001\u6700\u5927\u5316\u7a97\u53e3\uff0c\u6216\u5173\u95ed\u7a97\u53e3\u3002\u6bcf\u4e2a\u7a97\u53e3\u90fd\u662f\u72ec\u7acb\u7684\uff0c\u53ef\u4ee5\u6a21\u62df\u4e00\u4e2a\u7c7b\u4f3c Windows \u684c\u9762\u4e0a\u7684\u7a97\u53e3\u754c\u9762\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e2a\u7b80\u5355\u7684\u5b9e\u73b0\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6269\u5c55\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u66f4\u591a\u7684\u7a97\u53e3\u63a7\u5236<\/strong>\uff1a\u4f8b\u5982\u5b9e\u73b0\u591a\u4e2a\u7a97\u53e3\u7684\u6392\u5217\u3001\u4efb\u52a1\u680f\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u5b9a\u4e49\u7a97\u53e3\u6837\u5f0f<\/strong>\uff1a\u53ef\u4ee5\u901a\u8fc7 CSS \u81ea\u5b9a\u4e49\u6bcf\u4e2a\u7a97\u53e3\u7684\u6837\u5f0f\uff0c\u4f7f\u5176\u66f4\u52a0\u50cf Windows \u7cfb\u7edf\u4e2d\u7684\u7a97\u53e3\u3002<\/li>\n\n\n\n<li><strong>\u589e\u5f3a\u7684\u529f\u80fd<\/strong>\uff1a\u4f8b\u5982\u62d6\u653e\u6587\u4ef6\u5230\u7a97\u53e3\u4e2d\u3001\u7a97\u53e3\u53e0\u52a0\u3001\u6a21\u6001\u7a97\u53e3\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f7f\u7528 HTML\u3001CSS \u548c JavaScript\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u4eff Windows \u684c\u9762\u73af\u5883\u7684\u7f51\u9875\uff0c\u63d0\u4f9b\u684c\u9762\u7a97\u53e3\u7684\u4e92\u52a8\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 HTML \u548c CSS \u4e2d\u5b9e\u73b0\u4eff Windows \u684c\u9762\u4e3b\u9898\u7279\u6548\uff0c\u901a\u5e38\u4f1a\u6d89\u53ca\u5230\u591a&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/20\/html%e5%ae%9e%e7%8e%b0%e4%bb%bfwindows%e6%a1%8c%e9%9d%a2%e4%b8%bb%e9%a2%98%e7%89%b9%e6%95%88%e7%9a%84%e5%ae%9e%e7%8e%b0\/\">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-51","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\/51","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=51"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":52,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/51\/revisions\/52"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}