{"id":27901,"date":"2024-11-24T09:43:46","date_gmt":"2024-11-24T01:43:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27901\/"},"modified":"2024-11-24T09:43:46","modified_gmt":"2024-11-24T01:43:46","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8-css-grid-%e5%b8%83%e5%b1%80%e8%a7%a3%e5%86%b3%e5%88%97%e6%95%b0%e4%b8%8d%e8%b6%b3%e5%92%8c%e5%85%83%e7%b4%a0%e5%ae%bd%e5%ba%a6%e4%b8%8d%e4%b8%80%e8%87%b4%e9%97%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27901\/","title":{"rendered":"\u5982\u4f55\u5229\u7528 CSS Grid \u5e03\u5c40\u89e3\u51b3\u5217\u6570\u4e0d\u8db3\u548c\u5143\u7d20\u5bbd\u5ea6\u4e0d\u4e00\u81f4\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173133091311031.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5229\u7528 CSS Grid \u5e03\u5c40\u89e3\u51b3\u5217\u6570\u4e0d\u8db3\u548c\u5143\u7d20\u5bbd\u5ea6\u4e0d\u4e00\u81f4\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5229\u7528 CSS Grid \u5e03\u5c40\u89e3\u51b3\u5217\u6570\u4e0d\u8db3\u548c\u5143\u7d20\u5bbd\u5ea6\u4e0d\u4e00\u81f4\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728  grid \u5e03\u5c40\u4e2d\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\uff1f<\/strong><\/p>\n<p>\u539f\u59cb\u95ee\u9898\u5305\u542b\u4e24\u4e2a\u5e38\u89c1\u7684 CSS Grid \u5e03\u5c40\u95ee\u9898\uff1a<\/p>\n<p><strong>\u95ee\u9898 1\uff1a\u5b9e\u73b0 1 \u884c 5 \u5217<\/strong><\/p>\n<p>\u539f\u4ee3\u7801\u4f7f\u7528 grid-template-columns: repeat(auto-fill, 20%)\uff0c\u4f46\u4e0d\u8db3\u4ee5\u5728 1 \u884c\u4e2d\u663e\u793a 5 \u4e2a\u5143\u7d20\u3002\u89e3\u51b3\u65b9\u6848\u662f\u4f7f\u7528 repeat(auto-fit, calc()) \u51fd\u6570\uff0c\u8be5\u51fd\u6570\u5141\u8bb8\u8ba1\u7b97\u6bcf\u4e00\u5217\u7684\u5bbd\u5ea6\uff0c\u4f7f\u5176\u586b\u5145\u53ef\u7528\u7a7a\u95f4\uff0c\u5e76\u4fdd\u7559\u6307\u5b9a\u7684\u5217\u95f4\u8ddd\uff1a<\/p>\n<pre>grid-template-columns: repeat(auto-fit, calc((100% - 4 * 20px) \/ 5));<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u95ee\u9898 2\uff1a\u4e0d\u8db3 5 \u4e2a\u5143\u7d20\u65f6 li \u5bbd\u5ea6\u589e\u52a0<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>grid-template-columns: auto auto auto auto auto; \u8bbe\u7f6e\u4e86 5 \u4e2a\u81ea\u52a8\u5217\u3002\u5f53 li \u6570\u91cf\u4e0d\u8db3 5 \u4e2a\u65f6\uff0c\u81ea\u52a8\u5217\u4f1a\u5438\u6536\u53ef\u7528\u7a7a\u95f4\uff0c\u5bfc\u81f4 li \u5bbd\u5ea6\u589e\u52a0\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 fr \u5355\u4f4d\uff0c\u5b83\u6839\u636e\u53ef\u7528\u7a7a\u95f4\u5206\u914d\u5217\u5bbd\u5ea6\uff1a<\/p>\n<pre>grid-template-columns: 1fr 1fr 1fr 1fr 1fr;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5229\u7528 CSS Grid \u5e03\u5c40\u89e3\u51b3\u5217\u6570\u4e0d\u8db3\u548c\u5143\u7d20\u5bbd\u5ea6\u4e0d\u4e00\u81f4\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>\u5982\u4f55\u5728 grid \u5e03\u5c40\u4e2d\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\uff1f \u539f\u59cb\u95ee\u9898\u5305\u542b\u4e24\u4e2a\u5e38\u89c1\u7684 CSS Grid \u5e03\u5c40\u95ee\u9898\uff1a \u95ee\u9898 1\uff1a\u5b9e\u73b0 1 \u884c 5 \u5217 \u539f\u4ee3\u7801\u4f7f\u7528 grid-template-columns: repeat(auto-fill, 20%)\uff0c\u4f46\u4e0d\u8db3\u4ee5\u5728 1 \u884c\u4e2d\u663e\u793a 5 \u4e2a\u5143\u7d20\u3002\u89e3\u51b3\u65b9\u6848\u662f\u4f7f\u7528 repeat(auto-fit, calc()) \u51fd\u6570\uff0c\u8be5\u51fd\u6570\u5141\u8bb8\u8ba1\u7b97\u6bcf\u4e00\u5217\u7684\u5bbd\u5ea6\uff0c\u4f7f\u5176\u586b\u5145\u53ef\u7528\u7a7a\u95f4\uff0c\u5e76\u4fdd\u7559\u6307\u5b9a\u7684\u5217\u95f4\u8ddd\uff1a grid-template-columns: repeat(auto-fit, calc((100% &#8211; 4 * 20px) \/ 5)); \u767b\u5f55\u540e\u590d\u5236 \u95ee\u9898 2\uff1a\u4e0d\u8db3 5 \u4e2a\u5143\u7d20\u65f6 li \u5bbd\u5ea6\u589e\u52a0 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b grid-template-columns: auto auto auto auto auto; \u8bbe\u7f6e\u4e86 5 \u4e2a\u81ea\u52a8\u5217\u3002\u5f53 li \u6570\u91cf\u4e0d\u8db3 5 \u4e2a\u65f6\uff0c\u81ea\u52a8\u5217\u4f1a\u5438\u6536\u53ef\u7528\u7a7a\u95f4\uff0c\u5bfc\u81f4 li [&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-27901","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27901","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=27901"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27901\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}