{"id":28164,"date":"2024-11-24T17:01:11","date_gmt":"2024-11-24T09:01:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28164\/"},"modified":"2024-11-24T17:01:11","modified_gmt":"2024-11-24T09:01:11","slug":"%e7%a7%bb%e5%8a%a8%e7%ab%af%e6%b5%8f%e8%a7%88%e5%99%a8%e9%ab%98%e5%ba%a6%e4%b8%8e%e5%9c%b0%e5%9d%80%e5%b7%a5%e5%85%b7%e6%a0%8f%ef%bc%9a%e5%a6%82%e4%bd%95%e6%9c%89%e6%95%88%e6%8e%a7%e5%88%b6%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28164\/","title":{"rendered":"\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\uff1a\u5982\u4f55\u6709\u6548\u63a7\u5236\u9875\u9762\u5e03\u5c40\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173141566666528.jpg\" class=\"aligncenter\" title=\"\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\uff1a\u5982\u4f55\u6709\u6548\u63a7\u5236\u9875\u9762\u5e03\u5c40\uff1f\u63d2\u56fe\" alt=\"\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\uff1a\u5982\u4f55\u6709\u6548\u63a7\u5236\u9875\u9762\u5e03\u5c40\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f<\/strong><\/p>\n<p>\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\u7684\u5173\u7cfb\u4e00\u76f4\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u63a7\u5236\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5de5\u5177\u680f\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u7684\u503c\u3002<\/p>\n<p><strong>100vh<\/strong><\/p>\n<p>100vh \u8868\u793a\u89c6\u7a97\u9ad8\u5ea6\uff0c\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\u548c\u4e3b\u89c6\u533a\u3002\u5f53\u6d4f\u89c8\u5668\u6eda\u52a8\u65f6\uff0c\u5730\u5740\u5de5\u5177\u680f\u4f1a\u9690\u85cf\uff0c\u56e0\u6b64 100vh \u7684\u9ad8\u5ea6\u4f1a\u968f\u4e4b\u51cf\u5c11\u3002<\/p>\n<p><strong>innerHeight<\/strong><\/p>\n<p>innerHeight \u8868\u793a\u7a97\u53e3\u5185\u90e8\u53ef\u89c6\u533a\u57df\u7684\u9ad8\u5ea6\uff0c\u5b83\u4e0d\u5305\u542b\u5730\u5740\u5de5\u5177\u680f\u7684\u9ad8\u5ea6\u3002\u56e0\u6b64\uff0cinnerHeight \u7684\u9ad8\u5ea6\u5728\u6d4f\u89c8\u5668\u6eda\u52a8\u65f6\u4e0d\u4f1a\u6539\u53d8\u3002<\/p>\n<p><strong>dvh \u548c svh<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u6eda\u52a8\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 dvh (device viewport height) \u548c svh (safe viewport height)\u3002dvh \u8868\u793a\u8bbe\u5907\u89c6\u53e3\u9ad8\u5ea6\uff0c\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\uff0c\u4f46\u4e0d\u4f1a\u53d7\u6eda\u52a8\u5f71\u54cd\u3002svh \u8868\u793a\u5b89\u5168\u89c6\u53e3\u9ad8\u5ea6\uff0c\u4e0d\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\u548c\u6eda\u52a8\u6761\u3002<\/p>\n<p><strong>\u63a7\u5236\u4e0d\u53ef\u6eda\u52a8\u6548\u679c<\/strong><\/p>\n<p>\u8981\u8fbe\u5230\u4e0d\u53ef\u6eda\u52a8\u7684\u6548\u679c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 : hidden \u6837\u5f0f\u3002\u6b64\u6837\u5f0f\u5c06\u963b\u6b62\u5185\u5bb9\u533a\u57df\u6eda\u52a8\uff0c\u4f46\u4ecd\u7136\u5141\u8bb8\u9875\u9762\u5185\u5bb9\u81ea\u9002\u5e94\u7a97\u53e3\u5927\u5c0f\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<pre>&lt;style&gt;\n  body, html {\n    margin: 0;\n    height: 100vh;\n    overflow: hidden;\n  }\n  .container {\n    width: 100%;\n    height: 100vh;\n    background: linear-gradient(to bottom, #000, #e5e5e5);\n    font-size: 30px;\n    color: lightblue;\n    border: 1px solid red;\n    box-sizing: border-box;\n  }\n&lt;\/style&gt;\n&lt;body&gt;\n  &lt;div class=\"container\"&gt;\u6d4f\u89c8\u5668\u53ef\u89c6\u7a97\u53e3&lt;\/div&gt;\n&lt;\/body&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\uff1a\u5982\u4f55\u6709\u6548\u63a7\u5236\u9875\u9762\u5e03\u5c40\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>\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f \u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5730\u5740\u5de5\u5177\u680f\u7684\u5173\u7cfb\u4e00\u76f4\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u63a7\u5236\u6d4f\u89c8\u5668\u9ad8\u5ea6\u4e0e\u5de5\u5177\u680f\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u7684\u503c\u3002 100vh 100vh \u8868\u793a\u89c6\u7a97\u9ad8\u5ea6\uff0c\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\u548c\u4e3b\u89c6\u533a\u3002\u5f53\u6d4f\u89c8\u5668\u6eda\u52a8\u65f6\uff0c\u5730\u5740\u5de5\u5177\u680f\u4f1a\u9690\u85cf\uff0c\u56e0\u6b64 100vh \u7684\u9ad8\u5ea6\u4f1a\u968f\u4e4b\u51cf\u5c11\u3002 innerHeight innerHeight \u8868\u793a\u7a97\u53e3\u5185\u90e8\u53ef\u89c6\u533a\u57df\u7684\u9ad8\u5ea6\uff0c\u5b83\u4e0d\u5305\u542b\u5730\u5740\u5de5\u5177\u680f\u7684\u9ad8\u5ea6\u3002\u56e0\u6b64\uff0cinnerHeight \u7684\u9ad8\u5ea6\u5728\u6d4f\u89c8\u5668\u6eda\u52a8\u65f6\u4e0d\u4f1a\u6539\u53d8\u3002 dvh \u548c svh \u4e3a\u4e86\u89e3\u51b3\u6eda\u52a8\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 dvh (device viewport height) \u548c svh (safe viewport height)\u3002dvh \u8868\u793a\u8bbe\u5907\u89c6\u53e3\u9ad8\u5ea6\uff0c\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\uff0c\u4f46\u4e0d\u4f1a\u53d7\u6eda\u52a8\u5f71\u54cd\u3002svh \u8868\u793a\u5b89\u5168\u89c6\u53e3\u9ad8\u5ea6\uff0c\u4e0d\u5305\u62ec\u5730\u5740\u5de5\u5177\u680f\u548c\u6eda\u52a8\u6761\u3002 \u63a7\u5236\u4e0d\u53ef\u6eda\u52a8\u6548\u679c \u8981\u8fbe\u5230\u4e0d\u53ef\u6eda\u52a8\u7684\u6548\u679c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 : hidden \u6837\u5f0f\u3002\u6b64\u6837\u5f0f\u5c06\u963b\u6b62\u5185\u5bb9\u533a\u57df\u6eda\u52a8\uff0c\u4f46\u4ecd\u7136\u5141\u8bb8\u9875\u9762\u5185\u5bb9\u81ea\u9002\u5e94\u7a97\u53e3\u5927\u5c0f\u3002 \u793a\u4f8b\u4ee3\u7801 &lt;style&gt; body, html { margin: 0; height: 100vh; overflow: hidden; } .container { width: 100%; height: 100vh; background: linear-gradient(to bottom, #000, #e5e5e5); font-size: [&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-28164","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28164","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=28164"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28164\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}