{"id":497,"date":"2022-10-10T21:56:13","date_gmt":"2022-10-10T13:56:13","guid":{"rendered":"http:\/\/gjweb.top\/?p=497"},"modified":"2022-10-10T21:56:15","modified_gmt":"2022-10-10T13:56:15","slug":"%e6%a0%b9%e6%8d%ae%e7%b3%bb%e7%bb%9f%e4%b8%bb%e9%a2%98%e5%8a%a8%e6%80%81%e5%88%87%e6%8d%a2%e5%89%8d%e7%ab%af%e9%a2%9c%e8%89%b2","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=497","title":{"rendered":"\u6839\u636e\u7cfb\u7edf\u4e3b\u9898\u52a8\u6001\u5207\u6362\u524d\u7aef\u989c\u8272"},"content":{"rendered":"\n<p>\u4ee5 windows \u7cfb\u7edf\u4e3a\u4f8b \u53d8\u6362\u4e3b\u9898\u989c\u8272\u6d4f\u89c8\u5668\u9875\u9762\u4f1a\u6839\u636e\u4e3b\u9898\u81ea\u52a8\u5207\u6362\u76f8\u5e94\u7684\u989c\u8272<\/p>\n\n\n\n<p>\u8bdd\u4e0d\u591a\u8bf4\u8fdb\u5165\u6b63\u6587<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"css\u89e3\u51b3\u65b9\u6848\">CSS\u89e3\u51b3\u65b9\u6848<\/h2>\n\n\n\n<p>css \u89e3\u51b3\u65b9\u6848\u9700\u8981\u501f\u52a9 css3\u7684\u65b0\u7279\u6027 <em>prefers-color-scheme<\/em> \u8fd4\u56de no-preference ( \u672a\u77e5 ) \\ light ( \u6d45\u8272 ) \\ dark ( \u6df1\u8272 )<\/p>\n\n\n\n<p>\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;<br>&lt;html lang=\"en\"&gt;<br>&lt;head&gt;<br> &nbsp;&lt;meta charset=\"UTF-8\"&gt;<br> &nbsp;&lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;<br> &nbsp;&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;<br> &nbsp;&lt;title&gt;Document&lt;\/title&gt;<br> &nbsp;&lt;style&gt;<br> &nbsp;  *{<br> &nbsp; &nbsp; &nbsp;margin:0px;<br> &nbsp; &nbsp; &nbsp;padding: 0px;<br> &nbsp; &nbsp; &nbsp;box-sizing: border-box;<br> &nbsp;  }<br> &nbsp; &nbsp;\/* \u6d45\u8272\u4e3b\u9898 *\/<br> &nbsp; &nbsp;@media(prefers-color-scheme: light){ <br> &nbsp; &nbsp; &nbsp;body{<br> &nbsp; &nbsp; &nbsp; &nbsp;background: #eee;<br> &nbsp; &nbsp; &nbsp; &nbsp;color:#222<br> &nbsp; &nbsp;  }<br>\u200b<br> &nbsp;  }<br> &nbsp; &nbsp;\/*\u6697\u8272\u4e3b\u9898*\/<br> &nbsp; &nbsp;@media(prefers-color-scheme: dark){<br> &nbsp; &nbsp; &nbsp;body{<br> &nbsp; &nbsp; &nbsp; &nbsp;background: #222;<br> &nbsp; &nbsp; &nbsp; &nbsp;color:#eee<br> &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp;&lt;\/style&gt;<br>&lt;\/head&gt;<br>&lt;body&gt;<br> &nbsp;&lt;h1&gt;\u53d8\u6362\u4e3b\u9898\u8272&lt;\/h1&gt;<br>&lt;\/body&gt;<br>&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"js-\u89e3\u51b3\u65b9\u6848\">JS \u89e3\u51b3\u65b9\u6848<\/h2>\n\n\n\n<p>\u9700\u8981\u501f\u52a9 window.matchMedia() API \u6765\u76d1\u542c\u5f53\u524d\u4e3b\u9898\u7684\u53d8\u5316.<\/p>\n\n\n\n<p>\u793a\u4f8b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;<br>&lt;html lang=\"en\"&gt;<br>&lt;head&gt;<br> &nbsp;&lt;meta charset=\"UTF-8\"&gt;<br> &nbsp;&lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;<br> &nbsp;&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;<br> &nbsp;&lt;title&gt;Document&lt;\/title&gt;<br> &nbsp;&lt;style&gt;<br> &nbsp;  *{<br> &nbsp; &nbsp; &nbsp;margin:0px;<br> &nbsp; &nbsp; &nbsp;padding: 0px;<br> &nbsp; &nbsp; &nbsp;box-sizing: border-box;<br> &nbsp;  }<br> &nbsp; &nbsp;.light{<br> &nbsp; &nbsp; &nbsp;background: #eee;<br> &nbsp; &nbsp; &nbsp;color:#222<br> &nbsp;  }<br> &nbsp; &nbsp;.dark{<br> &nbsp; &nbsp; &nbsp;background: #222;<br> &nbsp; &nbsp; &nbsp;color:#eee<br> &nbsp;  }<br> &nbsp;&lt;\/style&gt;<br>&lt;\/head&gt;<br>&lt;body&gt;<br> &nbsp;&lt;h1&gt;\u53d8\u6362\u4e3b\u9898\u8272&lt;\/h1&gt;<br>&lt;\/body&gt;<br>&lt;\/html&gt;<br>&lt;script&gt;<br> &nbsp;let theme = window.matchMedia(\"(prefers-color-scheme: light)\")<br> &nbsp;let body = document.getElementsByTagName(\"body\")&#91;0]<br> &nbsp;if(theme.matches){body.className &nbsp;= \"light\"}<br> &nbsp;theme.onchange = (data)=&gt;{<br> &nbsp; &nbsp;console.log(data.matches,body)<br> &nbsp; &nbsp;if(data.matches){<br> &nbsp; &nbsp; &nbsp;body.className &nbsp;= \"light\"<br> &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp;body.className &nbsp;= \"dark\"<br> &nbsp;  }<br>  }<br>&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u6548\u679c\u5982\u4e0b\">\u6548\u679c\u5982\u4e0b<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409148430.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"789\" height=\"626\" data-original=\"http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409148430.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-498\"  sizes=\"auto, (max-width: 789px) 100vw, 789px\" \/><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409229742.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"316\" data-original=\"http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409229742.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-499\"  sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409177510.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"632\" data-original=\"http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409177510.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-500\"  sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409248994.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"338\" data-original=\"http:\/\/gjweb.top\/wp-content\/uploads\/2022\/10\/1665409248994.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-501\"  sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5 windows \u7cfb\u7edf\u4e3a\u4f8b \u53d8\u6362\u4e3b\u9898\u989c\u8272\u6d4f\u89c8\u5668\u9875\u9762\u4f1a\u6839\u636e\u4e3b\u9898\u81ea\u52a8\u5207\u6362\u76f8\u5e94\u7684\u989c\u8272 \u8bdd\u4e0d\u591a\u8bf4\u8fdb\u5165\u6b63\u6587 CSS\u89e3\u51b3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-497","post","type-post","status-publish","format-standard","hentry","category-38"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=497"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/497\/revisions"}],"predecessor-version":[{"id":502,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/497\/revisions\/502"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}