{"id":25570,"date":"2024-11-24T11:53:49","date_gmt":"2024-11-24T03:53:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25570\/"},"modified":"2024-11-24T11:53:49","modified_gmt":"2024-11-24T03:53:49","slug":"%e5%a6%82%e4%bd%95%e8%ae%a9%e7%88%b6%e5%ae%b9%e5%99%a8%e5%86%85%e7%9a%84%e6%89%80%e6%9c%89-div-%e6%a8%aa%e5%90%91%e6%8e%92%e5%88%97%ef%bc%8c%e9%ab%98%e5%ba%a6%e4%bf%9d%e6%8c%81%e4%b8%80%e8%87%b4-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25570\/","title":{"rendered":"\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 DIV \u6a2a\u5411\u6392\u5217\uff0c\u9ad8\u5ea6\u4fdd\u6301\u4e00\u81f4\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173063358422356.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 DIV \u6a2a\u5411\u6392\u5217\uff0c\u9ad8\u5ea6\u4fdd\u6301\u4e00\u81f4\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 DIV \u6a2a\u5411\u6392\u5217\uff0c\u9ad8\u5ea6\u4fdd\u6301\u4e00\u81f4\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 div \u6a2a\u5411\uff0c\u9ad8\u5ea6\u4fdd\u6301\u4e00\u81f4\uff1f<\/strong><\/p>\n<p>\u5728 CSS \u5e03\u5c40\u4e2d\uff0c\u5982\u4f55\u5b9e\u73b0\u8fd9\u6837\u7684\u6548\u679c\uff1a\u4e00\u4e2a\u7236\u5bb9\u5668\u5305\u542b\u591a\u4e2a DIV\uff0c\u8fd9\u4e9b DIV \u6a2a\u5411\u6392\u5217\uff0c\u4e14\u65e0\u8bba\u6bcf\u4e2a DIV \u5185\u7684\u5185\u5bb9\u591a\u5c11\uff0c\u5b83\u4eec\u7684<strong>\u9ad8\u5ea6\u59cb\u7ec8\u4fdd\u6301\u4e00\u81f4<\/strong>\uff0c\u65e2\u4e0d\u5141\u8bb8\u5185\u5bb9\u8d85\u51fa DIV \u9ad8\u5ea6\uff0c\u4e5f\u4e0d\u5f97\u56e0\u4e3a\u8fc7\u591a\u7684\u5185\u5bb9\u800c\u5bfc\u81f4\u4e2a\u522b DIV \u9ad8\u5ea6\u7a81\u51fa\uff1f<\/p>\n<p><strong>CSS \u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 flex \u5e03\u5c40\u6765\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e2a\u6548\u679c\u3002flex \u5e03\u5c40\u7684\u9ed8\u8ba4\u884c\u4e3a\u662f\u62c9\u4f38\u5bf9\u9f50\uff0c\u8fd9\u610f\u5473\u7740\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709\u5b50\u5143\u7d20\uff08DIV\uff09\u5c06\u88ab\u5782\u76f4\u62c9\u4f38\u4ee5\u5339\u914d\u7236\u5bb9\u5668\u7684\u9ad8\u5ea6\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f CSS \u4ee3\u7801\u7247\u6bb5\uff0c\u53ef\u5b9e\u73b0\u4e0a\u8ff0\u6548\u679c\uff1a<\/p>\n<pre>.flex {\n  display: flex;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53ea\u9700\u5c06 .flex \u7c7b\u9644\u52a0\u5230\u7236\u5bb9\u5668\u4e0a\uff0c\u5176\u5185\u90e8\u7684 DIV \u5c06\u81ea\u52a8\u6a2a\u5411\u6392\u5217\uff0c\u5e76\u4e14\u9ad8\u5ea6\u76f8\u540c\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4e0b\u9762\u7684 HTML \u548c CSS \u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 flex \u5e03\u5c40\u5b9e\u73b0\u8be5\u6548\u679c\uff1a<\/p>\n<pre>&lt;div class=\"flex\"&gt;\n  &lt;div&gt;DIV 1&lt;\/div&gt;\n  &lt;div&gt;DIV 2 with lots of content&lt;\/div&gt;\n  &lt;div&gt;DIV 3&lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.flex {\n  display: flex;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u5e94\u7528\u4e0a\u8ff0 CSS \u4ee3\u7801\u540e\uff0c\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 DIV \u5c06\u6a2a\u5411\u6392\u5217\uff0c\u5e76\u4e14\u65e0\u8bba\u5185\u5bb9\u591a\u5c11\uff0c\u5b83\u4eec\u7684<strong>\u9ad8\u5ea6\u90fd\u5c06\u4fdd\u6301\u4e00\u81f4<\/strong>\u3002 \u8fd9\u89e3\u51b3\u4e86\u4f60\u63d0\u51fa\u7684\u95ee\u9898\uff0c\u786e\u4fdd\u4e86\u6240\u6709 DIV \u5728\u9ad8\u5ea6\u4e0a\u4fdd\u6301\u4e00\u81f4\u7684\u6392\u5217\uff0c\u800c\u4e0d\u4f1a\u56e0\u4e3a\u4e2a\u522b DIV \u5185\u5bb9\u8fc7\u591a\u800c\u51fa\u73b0\u51f8\u51fa\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 DIV \u6a2a\u5411\uff0c\u9ad8\u5ea6\u4fdd\u6301\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>\u5982\u4f55\u8ba9\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709 div \u6a2a\u5411\uff0c\u9ad8\u5ea6\u4fdd\u6301\u4e00\u81f4\uff1f \u5728 CSS \u5e03\u5c40\u4e2d\uff0c\u5982\u4f55\u5b9e\u73b0\u8fd9\u6837\u7684\u6548\u679c\uff1a\u4e00\u4e2a\u7236\u5bb9\u5668\u5305\u542b\u591a\u4e2a DIV\uff0c\u8fd9\u4e9b DIV \u6a2a\u5411\u6392\u5217\uff0c\u4e14\u65e0\u8bba\u6bcf\u4e2a DIV \u5185\u7684\u5185\u5bb9\u591a\u5c11\uff0c\u5b83\u4eec\u7684\u9ad8\u5ea6\u59cb\u7ec8\u4fdd\u6301\u4e00\u81f4\uff0c\u65e2\u4e0d\u5141\u8bb8\u5185\u5bb9\u8d85\u51fa DIV \u9ad8\u5ea6\uff0c\u4e5f\u4e0d\u5f97\u56e0\u4e3a\u8fc7\u591a\u7684\u5185\u5bb9\u800c\u5bfc\u81f4\u4e2a\u522b DIV \u9ad8\u5ea6\u7a81\u51fa\uff1f CSS \u89e3\u51b3\u65b9\u6848 \u53ef\u4ee5\u4f7f\u7528 flex \u5e03\u5c40\u6765\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e2a\u6548\u679c\u3002flex \u5e03\u5c40\u7684\u9ed8\u8ba4\u884c\u4e3a\u662f\u62c9\u4f38\u5bf9\u9f50\uff0c\u8fd9\u610f\u5473\u7740\u7236\u5bb9\u5668\u5185\u7684\u6240\u6709\u5b50\u5143\u7d20\uff08DIV\uff09\u5c06\u88ab\u5782\u76f4\u62c9\u4f38\u4ee5\u5339\u914d\u7236\u5bb9\u5668\u7684\u9ad8\u5ea6\u3002 \u4ee5\u4e0b\u662f CSS \u4ee3\u7801\u7247\u6bb5\uff0c\u53ef\u5b9e\u73b0\u4e0a\u8ff0\u6548\u679c\uff1a .flex { display: flex; } \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u53ea\u9700\u5c06 .flex \u7c7b\u9644\u52a0\u5230\u7236\u5bb9\u5668\u4e0a\uff0c\u5176\u5185\u90e8\u7684 DIV \u5c06\u81ea\u52a8\u6a2a\u5411\u6392\u5217\uff0c\u5e76\u4e14\u9ad8\u5ea6\u76f8\u540c\u3002 \u793a\u4f8b \u4e0b\u9762\u7684 HTML \u548c CSS \u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 flex \u5e03\u5c40\u5b9e\u73b0\u8be5\u6548\u679c\uff1a &lt;div class=&#8221;flex&#8221;&gt; &lt;div&gt;DIV 1&lt;\/div&gt; &lt;div&gt;DIV 2 with lots of content&lt;\/div&gt; &lt;div&gt;DIV [&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-25570","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25570","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=25570"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25570\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}