{"id":27259,"date":"2024-11-24T11:03:45","date_gmt":"2024-11-24T03:03:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27259\/"},"modified":"2024-11-24T11:03:45","modified_gmt":"2024-11-24T03:03:45","slug":"overflow%e5%88%9b%e5%bb%ba%e7%9a%84bfc%e5%92%8cfloat%e5%88%9b%e5%bb%ba%e7%9a%84bfc%ef%bc%8c%e5%ae%83%e4%bb%ac%e7%9a%84%e5%b8%83%e5%b1%80%e8%a1%8c%e4%b8%ba%e4%b8%ba%e4%bd%95%e4%b8%8d%e5%90%8c-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27259\/","title":{"rendered":"overflow\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\uff0c\u5b83\u4eec\u7684\u5e03\u5c40\u884c\u4e3a\u4e3a\u4f55\u4e0d\u540c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173121896068313.jpg\" class=\"aligncenter\" title=\"overflow\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\uff0c\u5b83\u4eec\u7684\u5e03\u5c40\u884c\u4e3a\u4e3a\u4f55\u4e0d\u540c\uff1f\u63d2\u56fe\" alt=\"overflow\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\uff0c\u5b83\u4eec\u7684\u5e03\u5c40\u884c\u4e3a\u4e3a\u4f55\u4e0d\u540c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u521b\u5efa\u7684BFC\u4e0efloat\u521b\u5efa\u7684BFC\u4e4b\u95f4\u7684<\/strong><\/p>\n<p>Overflow\u521b\u5efa\u7684BFC\uff08\u5757\u7ea7\u683c\u5f0f\u5316\u4e0a\u4e0b\u6587\uff09\u548cfloat\u521b\u5efa\u7684BFC\u65e8\u5728\u5904\u7406\u5185\u5bb9\u5728\u7279\u5b9a\u533a\u57df\u5185\u7684\u5e03\u5c40\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b83\u4eec\u7684\u884c\u4e3a\u5374\u5927\u76f8\u5f84\u5ead\u3002<\/p>\n<p><strong>\u6ea2\u51fa\u521b\u5efa\u7684BFC<\/strong><\/p>\n<p>\u4f7f\u7528overflow: hidden\u521b\u5efa\u7684BFC\u4f1a\u521b\u5efa\u4e00\u4e2a\u5f3a\u5236\u5305\u542b\u5757\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u7684\u5bb9\u5668\u3002\u5373\u4f7f\u53f3\u4fa7\u6ca1\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u653e\u7f6e\u5185\u5bb9\uff0c\u6b64BFC\u4ecd\u7136\u5ef6\u4f38\u5230\u56fe\u50cf\u53f3\u4fa7\uff0c\u4ee5\u9002\u5e94\u6587\u672c\u3002<\/p>\n<p><strong>Floated \u521b\u5efa\u7684 BFC<\/strong><\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u4f7f\u7528float\u521b\u5efa\u7684BFC\u4f1a\u5c06\u5143\u7d20\u4ece\u6b63\u5e38\u6587\u6863\u6d41\u4e2d\u79fb\u9664\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u65c1\u8fb9\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6d6e\u52a8\u5143\u7d20\u4e0d\u5f71\u54cd\u540e\u7eed\u5143\u7d20\u7684\u5e03\u5c40\uff0c\u56e0\u6b64\u6587\u672c\u76f4\u63a5\u663e\u793a\u5728\u56fe\u50cf\u4e0b\u65b9\u3002\u53ea\u6709\u5f53\u6d6e\u52a8\u5143\u7d20\u7684\u5bbd\u5ea6\u51cf\u53bb\u8fb9\u8ddd\u548c\u586b\u5145\u540e\uff0c\u5176\u5185\u5bb9\u8d85\u51fa\u4e86\u53ef\u7528\u7684\u7a7a\u95f4\u65f6\uff0c\u5b83\u624d\u4f1a\u53e6\u8d77\u4e00\u884c\u3002<\/p>\n<p><strong>\u533a\u522b\u7684\u539f\u56e0<\/strong><\/p>\n<p>Overflow\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\u5b83\u4eec\u90fd\u662fBFC\u5e94\u8be5\u6ca1\u6709\u533a\u522b\u3002\u6545\u8fd9\u91cc\u7684\u884c\u4e3a\u4e0d\u540c\u8ddf\u662f\u600e\u4e48\u4ea7\u751f\u7684BFC\u662f\u6ca1\u6709\u5173\u7cfb\u7684\u3002<\/p>\n<p>\u8fd9\u5e94\u8be5\u548cblock width\u7684\u8ba1\u7b97\uff08width:auto or width: fit-content\uff09\u3001float\u5143\u7d20\u6d41\u51fanormal flow\u4ee5\u53cafloat\u4e0e\u4e4b\u540e\u7684bfc\u4e0d\u4f1a\u53d1\u751f\u91cd\u53e0\u6709\u5173\u3002<\/p>\n<ul>\n<li> <strong>float\u5143\u7d20\u6d41\u51fanormal flow\uff1a<\/strong>float\u5143\u7d20\u4e0d\u5c5e\u4e8enormal flow\uff0c\u56e0\u6b64\u540e\u7eed\u5143\u7d20\u5c06\u89c6\u5176\u4e0d\u5b58\u5728\u3002<\/li>\n<li> <strong>float\u5143\u7d20\u4e0ebfc\u4e0d\u4f1a\u91cd\u53e0\uff1a<\/strong>float\u5143\u7d20\u548c\u76f8\u90bb\u7684bfc\u4e0d\u4f1a\u91cd\u53e0\u3002\u8fd9\u8feb\u4f7fbfc\u53d8\u7a84\uff0c\u5360\u636e\u53ef\u7528\u5269\u4f59\u5bbd\u5ea6\u3002<\/li>\n<li> <strong>block width\u7684\u8ba1\u7b97\uff1a<\/strong>\u5982\u679cbfc\u7684\u5bbd\u5ea6\u8bbe\u7f6e\u4e3aauto\uff08\u5373\u201cshrink-to-fit\u201d\u5bbd\u5ea6\uff09\uff0c\u5219\u5f53\u6587\u672c\u5185\u5bb9\u8f83\u957f\u65f6\uff0cbfc\u5c06\u53d8\u7a84\u4ee5\u9002\u5e94\u5bbd\u5ea6\u3002\u7136\u800c\uff0c\u5f53\u6587\u672c\u8f83\u77ed\u65f6\uff0cbfc\u5c06\u6839\u636e\u5185\u5bb9\u786e\u5b9a\u5176\u5bbd\u5ea6\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u5176\u9ad8\u4e8e\u9884\u671f\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u56e0\u7d20\u5171\u540c\u5bfc\u81f4\u4e86float\u521b\u5efa\u7684BFC\u548coverflow\u521b\u5efa\u7684BFC\u5728\u5e03\u5c40\u884c\u4e3a\u4e0a\u7684\u5dee\u5f02\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\uff0c\u5b83\u4eec\u7684\u5e03\u5c40\u884c\u4e3a\u4e3a\u4f55\u4e0d\u540c\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>\u521b\u5efa\u7684BFC\u4e0efloat\u521b\u5efa\u7684BFC\u4e4b\u95f4\u7684 Overflow\u521b\u5efa\u7684BFC\uff08\u5757\u7ea7\u683c\u5f0f\u5316\u4e0a\u4e0b\u6587\uff09\u548cfloat\u521b\u5efa\u7684BFC\u65e8\u5728\u5904\u7406\u5185\u5bb9\u5728\u7279\u5b9a\u533a\u57df\u5185\u7684\u5e03\u5c40\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b83\u4eec\u7684\u884c\u4e3a\u5374\u5927\u76f8\u5f84\u5ead\u3002 \u6ea2\u51fa\u521b\u5efa\u7684BFC \u4f7f\u7528overflow: hidden\u521b\u5efa\u7684BFC\u4f1a\u521b\u5efa\u4e00\u4e2a\u5f3a\u5236\u5305\u542b\u5757\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u7684\u5bb9\u5668\u3002\u5373\u4f7f\u53f3\u4fa7\u6ca1\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u653e\u7f6e\u5185\u5bb9\uff0c\u6b64BFC\u4ecd\u7136\u5ef6\u4f38\u5230\u56fe\u50cf\u53f3\u4fa7\uff0c\u4ee5\u9002\u5e94\u6587\u672c\u3002 Floated \u521b\u5efa\u7684 BFC \u53e6\u4e00\u65b9\u9762\uff0c\u4f7f\u7528float\u521b\u5efa\u7684BFC\u4f1a\u5c06\u5143\u7d20\u4ece\u6b63\u5e38\u6587\u6863\u6d41\u4e2d\u79fb\u9664\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u65c1\u8fb9\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6d6e\u52a8\u5143\u7d20\u4e0d\u5f71\u54cd\u540e\u7eed\u5143\u7d20\u7684\u5e03\u5c40\uff0c\u56e0\u6b64\u6587\u672c\u76f4\u63a5\u663e\u793a\u5728\u56fe\u50cf\u4e0b\u65b9\u3002\u53ea\u6709\u5f53\u6d6e\u52a8\u5143\u7d20\u7684\u5bbd\u5ea6\u51cf\u53bb\u8fb9\u8ddd\u548c\u586b\u5145\u540e\uff0c\u5176\u5185\u5bb9\u8d85\u51fa\u4e86\u53ef\u7528\u7684\u7a7a\u95f4\u65f6\uff0c\u5b83\u624d\u4f1a\u53e6\u8d77\u4e00\u884c\u3002 \u533a\u522b\u7684\u539f\u56e0 Overflow\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\u5b83\u4eec\u90fd\u662fBFC\u5e94\u8be5\u6ca1\u6709\u533a\u522b\u3002\u6545\u8fd9\u91cc\u7684\u884c\u4e3a\u4e0d\u540c\u8ddf\u662f\u600e\u4e48\u4ea7\u751f\u7684BFC\u662f\u6ca1\u6709\u5173\u7cfb\u7684\u3002 \u8fd9\u5e94\u8be5\u548cblock width\u7684\u8ba1\u7b97\uff08width:auto or width: fit-content\uff09\u3001float\u5143\u7d20\u6d41\u51fanormal flow\u4ee5\u53cafloat\u4e0e\u4e4b\u540e\u7684bfc\u4e0d\u4f1a\u53d1\u751f\u91cd\u53e0\u6709\u5173\u3002 float\u5143\u7d20\u6d41\u51fanormal flow\uff1afloat\u5143\u7d20\u4e0d\u5c5e\u4e8enormal flow\uff0c\u56e0\u6b64\u540e\u7eed\u5143\u7d20\u5c06\u89c6\u5176\u4e0d\u5b58\u5728\u3002 float\u5143\u7d20\u4e0ebfc\u4e0d\u4f1a\u91cd\u53e0\uff1afloat\u5143\u7d20\u548c\u76f8\u90bb\u7684bfc\u4e0d\u4f1a\u91cd\u53e0\u3002\u8fd9\u8feb\u4f7fbfc\u53d8\u7a84\uff0c\u5360\u636e\u53ef\u7528\u5269\u4f59\u5bbd\u5ea6\u3002 block width\u7684\u8ba1\u7b97\uff1a\u5982\u679cbfc\u7684\u5bbd\u5ea6\u8bbe\u7f6e\u4e3aauto\uff08\u5373\u201cshrink-to-fit\u201d\u5bbd\u5ea6\uff09\uff0c\u5219\u5f53\u6587\u672c\u5185\u5bb9\u8f83\u957f\u65f6\uff0cbfc\u5c06\u53d8\u7a84\u4ee5\u9002\u5e94\u5bbd\u5ea6\u3002\u7136\u800c\uff0c\u5f53\u6587\u672c\u8f83\u77ed\u65f6\uff0cbfc\u5c06\u6839\u636e\u5185\u5bb9\u786e\u5b9a\u5176\u5bbd\u5ea6\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u5176\u9ad8\u4e8e\u9884\u671f\u3002 \u8fd9\u4e9b\u56e0\u7d20\u5171\u540c\u5bfc\u81f4\u4e86float\u521b\u5efa\u7684BFC\u548coverflow\u521b\u5efa\u7684BFC\u5728\u5e03\u5c40\u884c\u4e3a\u4e0a\u7684\u5dee\u5f02\u3002 \u4ee5\u4e0a\u5c31\u662f\u521b\u5efa\u7684BFC\u548cfloat\u521b\u5efa\u7684BFC\uff0c\u5b83\u4eec\u7684\u5e03\u5c40\u884c\u4e3a\u4e3a\u4f55\u4e0d\u540c\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27259","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27259","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=27259"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27259\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}