{"id":28140,"date":"2024-11-24T11:45:09","date_gmt":"2024-11-24T03:45:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28140\/"},"modified":"2024-11-24T11:45:09","modified_gmt":"2024-11-24T03:45:09","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-css-%e5%ae%9e%e7%8e%b0%e5%ad%90%e5%85%83%e7%b4%a0%e5%ae%bd%e5%ba%a6%e8%b6%85%e5%87%ba%e7%88%b6%e5%85%83%e7%b4%a0%e5%b9%b6%e5%8d%a0%e6%bb%a1%e6%95%b4%e4%b8%aa%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28140\/","title":{"rendered":"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u5b50\u5143\u7d20\u5bbd\u5ea6\u8d85\u51fa\u7236\u5143\u7d20\u5e76\u5360\u6ee1\u6574\u4e2a\u9875\u9762\uff0c\u540c\u65f6\u4fdd\u6301\u5b50\u5143\u7d20\u9ad8\u5ea6\u4e0e\u7236\u5143\u7d20\u4e00\u81f4\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173140601298306.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u5b50\u5143\u7d20\u5bbd\u5ea6\u8d85\u51fa\u7236\u5143\u7d20\u5e76\u5360\u6ee1\u6574\u4e2a\u9875\u9762\uff0c\u540c\u65f6\u4fdd\u6301\u5b50\u5143\u7d20\u9ad8\u5ea6\u4e0e\u7236\u5143\u7d20\u4e00\u81f4\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u5b50\u5143\u7d20\u5bbd\u5ea6\u8d85\u51fa\u7236\u5143\u7d20\u5e76\u5360\u6ee1\u6574\u4e2a\u9875\u9762\uff0c\u540c\u65f6\u4fdd\u6301\u5b50\u5143\u7d20\u9ad8\u5ea6\u4e0e\u7236\u5143\u7d20\u4e00\u81f4\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5e03\u5c40\u7684\u4e00\u4e2a\u5947\u8469\u9700\u6c42<\/strong><\/p>\n<p>\u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u79cd\u72ec\u7279\u7684 css \u5e03\u5c40\u9700\u6c42\uff0c\u5373\u5b9e\u73b0\u5b50\u5143\u7d20 box-2 \u7684\u9ad8\u5ea6\u7b49\u4e8e\u7236\u5143\u7d20 box-1 \u7684\u9ad8\u5ea6\uff0c\u540c\u65f6 box-2 \u5bbd\u5ea6\u8d85\u51fa box-1 \u5e76\u5360\u6ee1\u6574\u4e2a body\u3002<\/p>\n<p><strong>\u9700\u6c42:<\/strong><\/p>\n<ul>\n<li>\u4e0d\u6539\u53d8 html \u7ed3\u6784<\/li>\n<li>box-2 \u7684\u9ad8\u5ea6\u7b49\u4e8e box-1 \u7684\u9ad8\u5ea6\uff08\u5305\u62ec\u5185\u8fb9\u8ddd\uff09<\/li>\n<li>box-2 \u7684\u5bbd\u5ea6\u8d85\u51fa box-1 \u5e76\u5360\u6ee1 body<\/li>\n<\/ul>\n<p><strong>\u5b9e\u73b0:<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u4e14\u6709\u6548\u7684\u5b9e\u73b0\uff1a<\/p>\n<pre>&lt;style&gt;\n  body {\n    margin: 0;\n  }\n\n  .box-1 {\n    position: relative;\n  }\n\n  .box-2 {\n    width: 100vw;\n    height: 100%;\n    background-color: rgba(0, 0, 0, 0.2);\n    position: absolute;\n  }\n&lt;\/style&gt;\n\n&lt;div class=\"box-1 container py-5\"&gt;\n  &lt;div class=\"box-2\"&gt;&lt;\/div&gt;\n  &lt;div class=\"box-3\"&gt;\n    111 &lt;br&gt;\n    111 &lt;br&gt;\n    111 &lt;br&gt;\n    111 &lt;br&gt;\n    111 &lt;br&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bf4\u660e:<\/strong><\/p>\n<ul>\n<li>\u7531\u4e8e body \u7684 margin \u4e3a 0\uff0c\u56e0\u6b64 box-1 \u548c box-2 \u90fd\u5360\u636e\u4e86\u6574\u4e2a\u53ef\u89c6\u7a97\u53e3\u3002<\/li>\n<li>\u8bbe\u7f6e box-1 \u4e3a\uff0c\u521b\u5efa\u4e86\u5b50\u5143\u7d20 box-2 \u53ef\u4ee5\u6dfb\u52a0\u5230\u5176\u4e2d\u7684\u4e0a\u4e0b\u6587\u3002<\/li>\n<li>\u7ed9 box-2 \uff0c\u4f7f\u5176\u76f8\u5bf9\u4e8e box-1 \u5b9a\u4f4d\u3002<\/li>\n<li>\u5c06 box-2 \u7684\u5bbd\u5ea6\u8bbe\u7f6e\u4e3a 100vw\uff08100% \u7684\u89c6\u53e3\u5bbd\u5ea6\uff09\uff0c\u4f7f\u5176\u8d85\u51fa box-1 \u7684\u8303\u56f4\u3002<\/li>\n<li>\u7ed9 box-2 \u8bbe\u7f6e 100% \u7684\u9ad8\u5ea6\uff0c\u4f7f\u5176\u5339\u914d box-1 \u7684\u9ad8\u5ea6\uff08\u5305\u62ec\u5185\u8fb9\u8ddd\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u88dc\u5145:<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u4e3a box-1 \u8bbe\u7f6e\u6700\u5927\u5bbd\u5ea6\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b css\uff1a<\/p>\n<pre>&lt;style&gt;\n  .container {\n    max-width: 1000px;\n    margin: 0 auto;\n  }\n\n  .py-5 {\n    padding: 0 5em;\n  }\n&lt;\/style&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u9650\u5236 box-1 \u7684\u5bbd\u5ea6\u4e3a 1000px\uff0c\u5e76\u6c34\u5e73\u5c45\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u5b50\u5143\u7d20\u5bbd\u5ea6\u8d85\u51fa\u7236\u5143\u7d20\u5e76\u5360\u6ee1\u6574\u4e2a\u9875\u9762\uff0c\u540c\u65f6\u4fdd\u6301\u5b50\u5143\u7d20\u9ad8\u5ea6\u4e0e\u7236\u5143\u7d20\u4e00\u81f4\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>\u5e03\u5c40\u7684\u4e00\u4e2a\u5947\u8469\u9700\u6c42 \u672c\u6587\u5c06\u63a2\u8ba8\u4e00\u79cd\u72ec\u7279\u7684 css \u5e03\u5c40\u9700\u6c42\uff0c\u5373\u5b9e\u73b0\u5b50\u5143\u7d20 box-2 \u7684\u9ad8\u5ea6\u7b49\u4e8e\u7236\u5143\u7d20 box-1 \u7684\u9ad8\u5ea6\uff0c\u540c\u65f6 box-2 \u5bbd\u5ea6\u8d85\u51fa box-1 \u5e76\u5360\u6ee1\u6574\u4e2a body\u3002 \u9700\u6c42: \u4e0d\u6539\u53d8 html \u7ed3\u6784 box-2 \u7684\u9ad8\u5ea6\u7b49\u4e8e box-1 \u7684\u9ad8\u5ea6\uff08\u5305\u62ec\u5185\u8fb9\u8ddd\uff09 box-2 \u7684\u5bbd\u5ea6\u8d85\u51fa box-1 \u5e76\u5360\u6ee1 body \u5b9e\u73b0: \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u4e14\u6709\u6548\u7684\u5b9e\u73b0\uff1a &lt;style&gt; body { margin: 0; } .box-1 { position: relative; } .box-2 { width: 100vw; height: 100%; background-color: rgba(0, 0, 0, 0.2); position: absolute; } &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-28140","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28140","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=28140"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28140\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}