{"id":2805,"date":"2024-11-10T12:38:11","date_gmt":"2024-11-10T04:38:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2805\/"},"modified":"2024-11-10T12:38:11","modified_gmt":"2024-11-10T04:38:11","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e5%8a%a8%e6%80%81%e5%8d%95%e4%bd%8d%e5%92%8c%e5%93%8d%e5%ba%94%e5%bc%8f%e5%b8%83%e5%b1%80%e8%a7%a3%e5%86%b3%e9%a1%b5%e9%9d%a2%e5%a4%a7%e5%b0%8f%e5%8f%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2805\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u548c\u54cd\u5e94\u5f0f\u5e03\u5c40\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb\u7684\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173088397613175.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u548c\u54cd\u5e94\u5f0f\u5e03\u5c40\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb\u7684\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u548c\u54cd\u5e94\u5f0f\u5e03\u5c40\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb\u7684\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb<\/strong><\/p>\n<p>\u95ee\u9898\u4e2d\u63d0\u5230\u4f7f\u7528\u540e\uff0c\u9875\u9762\u5927\u5c0f\u53d8\u5316\u65f6\u56fe\u7247\u4f4d\u7f6e\u51fa\u73b0\u6f02\u79fb\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u914d\u5408\u54cd\u5e94\u5f0f\u5e03\u5c40<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u52a8\u6001\u5355\u4f4d\uff1a<\/strong><\/p>\n<ul>\n<li>vw\uff1a\u6d4f\u89c8\u5668\u5185\u7f6e\u5355\u4f4d\uff0c100vw \u7b49\u4e8e\u9875\u9762\u53ef\u89c6\u5bbd\u5ea6\u3002<\/li>\n<li>rem\uff1a\u76f8\u5bf9\u4e8e\u6839\u5143\u7d20\uff08\uff09\u7684\u5b57\u4f53\u5927\u5c0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u54cd\u5e94\u5f0f\u5e03\u5c40\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 @media \u5a92\u4f53\u67e5\u8be2\uff0c\u9488\u5bf9\u4e0d\u540c\u7684\u5c4f\u5e55\u5c3a\u5bf8\u8bbe\u7f6e\u4e0d\u540c\u7684\u6837\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong><\/p>\n<p><strong>\u52a8\u6001rem\u5b9e\u73b0\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u6839\u636e\u8bbe\u5907\u5927\u5c0f\u52a8\u6001\u8ba1\u7b97\u6839\u5143\u7d20\u5b57\u4f53\u5927\u5c0f\u7684 JavaScript \u51fd\u6570\u3002<\/li>\n<li>\u5c06\u8be5\u51fd\u6570\u4fdd\u5b58\u5728 \u6807\u7b7e\u4e2d\u3002<\/li>\n<\/ol>\n<p><strong>\u6837\u5f0f\u4fee\u6539\uff1a<\/strong><\/p>\n<ol>\n<li>\u4f7f\u7528 vw \u6216 rem \u7b49\u52a8\u6001\u5355\u4f4d\u8bbe\u5b9a\u56fe\u7247\u4f4d\u7f6e\u3002<\/li>\n<li>\u914d\u5408 @media \u5a92\u4f53\u67e5\u8be2\uff0c\u8bbe\u7f6e\u4e0d\u540c\u5c4f\u5e55\u5c3a\u5bf8\u4e0b\u7684\u56fe\u7247\u6837\u5f0f\u3002<\/li>\n<\/ol>\n<p><strong>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;head&gt;\n  &lt;script&gt;\n    function refreshRem() {\n      const whdef = 100 \/ 750;\n      const bodyWidth = document.body.clientWidth;\n      const rem = whdef * bodyWidth;\n      document.getElementsByTagName('html')[0].style.fontSize = `${rem}px`;\n    }\n  &lt;\/script&gt;\n  &lt;style&gt;\n    \/* ... *\/\n  &lt;\/style&gt;\n&lt;\/head&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u52a8\u6001\u8f93\u5165\u6846\u5b9e\u73b0\uff08\u4ec5\u4f9b\u53c2\u8003\uff0c\u53ef\u6839\u636e\u9700\u6c42\u4fee\u6539\uff09\uff1a<\/strong><\/p>\n<pre>&lt;input class=\"input\" type=\"text\" \/&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.input {\n  width: 20vw;\n  height: 3vw;\n  line-height: 3vw;\n  font-size: 1.5vw;\n  border: none;\n  outline: none;\n  border-radius: 2vw;\n  background: url(\u56fe\u72471) #fefdd7 17vw center\/2vw 2vw no-repeat;\n  box-shadow: 0 3px 0 0 #705048;\n  position: relative;\n  box-sizing: border-box;\n  padding: 0 4vw 0 2vw;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\uff0c\u56fe\u7247\u548c\u8f93\u5165\u6846\u7684\u4f4d\u7f6e\u5c06\u6839\u636e\u9875\u9762\u5927\u5c0f\u52a8\u6001\u8c03\u6574\uff0c\u786e\u4fdd\u65e0\u8bba\u9875\u9762\u5982\u4f55\u7f29\u653e\u90fd\u80fd\u4fdd\u6301\u6b63\u786e\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u548c\u54cd\u5e94\u5f0f\u5e03\u5c40\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb\u7684\u95ee\u9898\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u51b3\u9875\u9762\u5927\u5c0f\u53d8\u5316\u5bfc\u81f4\u56fe\u7247\u4f4d\u7f6e\u98d8\u79fb \u95ee\u9898\u4e2d\u63d0\u5230\u4f7f\u7528\u540e\uff0c\u9875\u9762\u5927\u5c0f\u53d8\u5316\u65f6\u56fe\u7247\u4f4d\u7f6e\u51fa\u73b0\u6f02\u79fb\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4f7f\u7528\u52a8\u6001\u5355\u4f4d\u914d\u5408\u54cd\u5e94\u5f0f\u5e03\u5c40 \u52a8\u6001\u5355\u4f4d\uff1a vw\uff1a\u6d4f\u89c8\u5668\u5185\u7f6e\u5355\u4f4d\uff0c100vw \u7b49\u4e8e\u9875\u9762\u53ef\u89c6\u5bbd\u5ea6\u3002 rem\uff1a\u76f8\u5bf9\u4e8e\u6839\u5143\u7d20\uff08\uff09\u7684\u5b57\u4f53\u5927\u5c0f\u3002 \u54cd\u5e94\u5f0f\u5e03\u5c40\uff1a \u4f7f\u7528 @media \u5a92\u4f53\u67e5\u8be2\uff0c\u9488\u5bf9\u4e0d\u540c\u7684\u5c4f\u5e55\u5c3a\u5bf8\u8bbe\u7f6e\u4e0d\u540c\u7684\u6837\u5f0f\u3002 \u4ee3\u7801\u5b9e\u73b0 \u52a8\u6001rem\u5b9e\u73b0\u6b65\u9aa4\uff1a \u521b\u5efa\u4e00\u4e2a\u6839\u636e\u8bbe\u5907\u5927\u5c0f\u52a8\u6001\u8ba1\u7b97\u6839\u5143\u7d20\u5b57\u4f53\u5927\u5c0f\u7684 JavaScript \u51fd\u6570\u3002 \u5c06\u8be5\u51fd\u6570\u4fdd\u5b58\u5728 \u6807\u7b7e\u4e2d\u3002 \u6837\u5f0f\u4fee\u6539\uff1a \u4f7f\u7528 vw \u6216 rem \u7b49\u52a8\u6001\u5355\u4f4d\u8bbe\u5b9a\u56fe\u7247\u4f4d\u7f6e\u3002 \u914d\u5408 @media \u5a92\u4f53\u67e5\u8be2\uff0c\u8bbe\u7f6e\u4e0d\u540c\u5c4f\u5e55\u5c3a\u5bf8\u4e0b\u7684\u56fe\u7247\u6837\u5f0f\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a &lt;head&gt; &lt;script&gt; function refreshRem() { const whdef = 100 \/ 750; const bodyWidth = document.body.clientWidth; const rem = whdef * bodyWidth; document.getElementsByTagName(&#8216;html&#8217;)[0].style.fontSize = `${rem}px`; } &lt;\/script&gt; &lt;style&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2805","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2805"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2805\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}