{"id":4588,"date":"2015-02-12T23:36:55","date_gmt":"2015-02-12T15:36:55","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4588"},"modified":"2019-10-07T22:53:14","modified_gmt":"2019-10-07T14:53:14","slug":"css-deep-understand-flow-bfc-column-two-auto-layout","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2015\/02\/css-deep-understand-flow-bfc-column-two-auto-layout\/","title":{"rendered":"CSS\u6df1\u5165\u7406\u89e3\u6d41\u4f53\u7279\u6027\u548cBFC\u7279\u6027\u4e0b\u591a\u680f\u81ea\u9002\u5e94\u5e03\u5c40"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/\">https:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=4588\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=4588<\/a><\/p>\n<h3>\u4e00\u3001\u5f00\u7bc7\u4e4b\u8a00<\/h3>\n<p>\u8981\u8bf4web\u4e0a\u5b9e\u73b0\u4e24\u680f\u81ea\u9002\u5e94\u5e03\u5c40\u7684\u65b9\u6cd5\uff0c\u4e00\u53cc\u624b\u90fd\u6570\u4e0d\u8fc7\u6765\u3002\u4e0d\u77e5\u5927\u5bb6\u6709\u6ca1\u6709\u7ec6\u60f3\u8fc7\uff0c\u4e3a\u4ec0\u4e48\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u81ea\u9002\u5e94\u5e03\u5c40\u5462\uff1f<img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/32.gif\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u5c31\u5c06\u6df1\u5165\u63a2\u8ba8\u4e0b\u6d41\u4f53\u7279\u6027\u548cBFC\u7279\u6027\u4e0b\u7684\u4e24\u680f\u81ea\u9002\u5e94\u5e03\u5c40\uff0c\u8fd8\u662f\u9488\u5bf9\u4f20\u7edf\u5e03\u5c40\u3002\u4e00\u4e9b\u73b0\u4ee3\u5e03\u5c40\uff0c\u5982\u5f39\u6027\u76d2\u5b50\u6a21\u578b\u5e03\u5c40(Flexbox Layout)\uff0c\u683c\u6805\u5e03\u5c40(Grid Layout)\u4e0d\u5728\u672c\u6587\u63a2\u8ba8\u4e4b\u7c7b\u3002<\/p>\n<blockquote><p>\u6709\u4e9b\u4eba\u770b\u4e86\u4e2a\u6807\u9898\uff0c\u4ee5\u53ca\u770b\u4e86\u524d\u9762\u4e00\u4e24\u6bb5\uff0c\u53d1\u73b0\uff0c\u90fd\u662f\u6211\u77e5\u9053\u7684\u6982\u5ff5\u561b\uff0c\u4ec0\u4e48\u6d41\u52a8\u6027\uff0c\u4ec0\u4e48BFC~~\u4e8e\u662f\uff0c\u5c31\u60bb\u60bb\u79bb\u5f00\u4e86\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u5e38\u8bf4\u7684\u6d6e\u8e81\uff0c\u4fdd\u6301\u4e00\u9897\u8c26\u900a\u7684\u5fc3\uff0c\u7ec6\u7ec6\u9605\u8bfb\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u5176\u4e2d\u4e00\u5b9a\u6709\u4f60\u6240\u6ca1\u6709\u5173\u6ce8\u8fc7\u7684\u5730\u65b9\uff0c\u6240\u8c13\u4e09\u4eba\u884c\u5fc5\u6709\u6211\u5e08\u3002\u6ca1\u9519\uff0c\u8fd9\u53e5\u8bdd\u5c31\u662f\u5199\u7ed9\u4f60\u770b\u7684\uff0c\u540c\u65f6\u4e5f\u662f\u81ea\u6211\u5185\u7701\u4e0e\u76d1\u7763\u3002<\/p><\/blockquote>\n<h3>\u4e8c\u3001\u5757\u72b6\u5143\u7d20\u7684\u6d41\u4f53\u7279\u6027\u4e0e\u81ea\u9002\u5e94\u5e03\u5c40<\/h3>\n<p><strong>\u6d41\u4f53\u7279\u6027<\/strong><br \/>\n\u5757\u72b6\u6c34\u5e73\u5143\u7d20\uff0c\u5982<code>div<\/code>\u5143\u7d20\uff08\u4e0b\u540c\uff09\uff0c\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff08\u975e\u6d6e\u52a8\u3001\u7edd\u5bf9\u5b9a\u4f4d\u7b49\uff09\uff0c\u6c34\u5e73\u65b9\u5411\u4f1a\u81ea\u52a8\u586b\u6ee1\u5916\u90e8\u7684\u5bb9\u5668\uff1b\u5982\u679c\u6709<code>margin-left\/margin-right<\/code>, <code>padding-left\/padding-right<\/code>, <code>border-left-width\/border-right-width<\/code>\u7b49\uff0c\u5b9e\u9645\u5185\u5bb9\u533a\u57df\u4f1a\u54cd\u5e94\u53d8\u7a84\u3002<\/p>\n<p>\u4e00\u56fe\u80dc\u5343\u8a00\uff0c\u4e00\u4f8b\u80dc\u5343\u56fe\u3002\u53ef\u53c2\u8003\u4e0b\u9762\u4f8b\u5b50\uff0c\u611f\u53d7\u4e0b<code>div<\/code>\u5143\u7d20\u7684\u6d41\u4f53\u7279\u6027\uff1a<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/div-flow.html\" width=\"510\" height=\"520\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u56fe\u7247\u5bbd\u5ea6\u4e00\u76f4<code>width:100%<\/code>\uff0c\u4f9d\u6b21\u70b9\u51fb3\u4e2a\u6309\u94ae\uff0c\u7ed3\u679c\u968f\u7740<code>margin<\/code>, <code>padding<\/code>, <code>border<\/code>\u7684\u51fa\u73b0\uff0c\u5176\u53ef\u7528\u5bbd\u5ea6\u81ea\u52a8\u8ddf\u7740\u51cf\u5c0f\uff0c\u5f62\u6210\u4e86\u81ea\u9002\u5e94\u6548\u679c\u3002\u5c31\u50cf\u653e\u5728\u5bb9\u5668\u4e2d\u7684\u6c34\u6d41\u4e00\u6837\uff0c\u5185\u5bb9\u533a\u57df\u4f1a\u968f\u7740<code>margin<\/code>, <code>padding<\/code>, <code>border<\/code>\u7684\u51fa\u73b0\u81ea\u52a8\u586b\u6ee1\u5269\u4f59\u7a7a\u95f4\uff0c\u8fd9\u5c31\u662f\u5757\u72b6\u5143\u7d20\u7684\u6d41\u4f53\u7279\u6027\u3002<\/p>\n<p><strong>\u6d41\u4f53\u7279\u6027<\/strong><br \/>\n\u4e0b\u9762\uff0c\u6211\u4eec\u7a0d\u5fae\u505a\u4e00\u4e2a\u8c03\u6574\uff0c<code>div<\/code>\u8ddd\u79bb\u5bb9\u5668\u5de6\u4fa7<code>margin<\/code> <code>150<\/code>\u50cf\u7d20\uff0c\u91cc\u9762\u7684\u56fe\u7247\u540c\u6837<code>100%<\/code>\u81ea\u9002\u5e94\u5185\u5bb9\u533a\u57df\u3002HTML\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\r\n.flow-box {\r\n    width: 500px; background-color: #eee; overflow:auto; resize:horizontal;\r\n}\r\n.flow-content {\r\n    margin-left: 150px;\r\n}\r\n<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>\r\n&lt;div class=\"flow-box\">\r\n    &lt;div class=\"flow-content\">&lt;img src=\"mm1.jpg\" width=\"100%\" height=\"190\">&lt;\/div>\r\n&lt;\/div>\r\n<\/pre>\n<\/div>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/margin-left.html\" width=\"100%\" height=\"215\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u56fe\u7247\u53f3\u4e0b\u89d2\u6709\u4e24\u9053\u659c\u6760\uff0c\u6211\u4eec\u53ef\u4ee5resize\u62c9\u4f38\uff08\u73b0\u4ee3\u6d4f\u89c8\u5668\uff0c\u4e14\u975e\u79fb\u52a8\u8bbf\u95ee\uff09\uff0c\u4f1a\u53d1\u73b0\uff0c\u5de6\u4fa7\u6c38\u8fdc150\u50cf\u7d20\u7559\u767d\uff0c\u800c\u56fe\u7247\u968f\u7740\u5bb9\u5668\u5bbd\u5ea6\u53d8\u5316\u800c\u81ea\u9002\u5e94\u53d8\u5316\u4e86\u3002<\/p>\n<p>\u6b64\u65f6\uff0c\u6211\u4eec\u9700\u8981\u597d\u597d\u5229\u7528\u5de6\u4fa7150\u50cf\u7d20\u7684\u7559\u767d\u95f4\u8ddd\uff0c\u5c82\u4e0d\u662f\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4e24\u680f\u81ea\u9002\u5e94\u6548\u679c\uff01\uff1f<\/p>\n<p>\u4e3a\u4e86\u4e0d\u5f71\u54cd\u539f\u672c\u7684\u6d41\u4f53\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7834\u574f\u6027\u5c5e\u6027\uff0c\u5982\u6d6e\u52a8(float:left)\uff0c\u6216\u8005\u7edd\u5bf9\u5b9a\u4f4d(position:absolute)\u3002<\/p>\n<p>\u6211\u4eec\u76f4\u63a5HTML\u5982\u4e0b\u8c03\u6574\u5373\u53ef\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\r\n&lt;div class=\"flow-box\">\r\n    &lt;img src=\"mm1.jpg\" width=\"128\" style=\"float:left;\">\r\n    &lt;div class=\"flow-content\">&lt;img src=\"mm1.jpg\" width=\"100%\" height=\"190\">&lt;\/div>\r\n&lt;\/div>\r\n<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>\r\n&lt;div class=\"flow-box\">\r\n    &lt;img src=\"mm1.jpg\" width=\"128\" style=\"position:absolute;\">\r\n    &lt;div class=\"flow-content\">&lt;img src=\"mm1.jpg\" width=\"100%\" height=\"190\">&lt;\/div>\r\n&lt;\/div>\r\n<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5206\u522b\u5982\u4e0b\uff1a<br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/float-flow.html\" width=\"100%\" height=\"215\" frameborder=\"0\"><\/iframe><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/absolute-flow.html\" width=\"100%\" height=\"215\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u5f53\u7136\uff0c\u4f60\u53ef\u4ee5\u5de6\u4fa7\u6709\u591a\u4e2a\u6d6e\u52a8\uff0c\u6216\u8005\u5de6\u6d6e\u52a8+\u53f3\u6d6e\u52a8\u3002\u4e8e\u662f\uff0c\u6211\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u5b9e\u73b0\u4e24\u680f\u81ea\u9002\u5e94\u6548\u679c\uff0c\u591a\u680f\u81ea\u9002\u5e94\u6548\u679c\u4e5f\u4e0d\u5728\u8bdd\u4e0b\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5229\u7528\u5757\u72b6\u5143\u7d20\u6d41\u4f53\u7279\u6027\u5b9e\u73b0\u7684\u81ea\u9002\u5e94\u5e03\u5c40\u6709\u4e2a\u4e0d\u8db3\uff0c\u5c31\u662f\uff0c\u6211\u4eec\u9700\u8981\u77e5\u9053\u6d6e\u52a8\u6216\u7edd\u5bf9\u5b9a\u4f4d\u5185\u5bb9\u7684\u5c3a\u5bf8\u3002\u7136\u540e\uff0c\u6d41\u4f53\u5185\u5bb9\u624d\u80fd\u6709\u5bf9\u5e94\u7684<code>margin<\/code>\u6216<code>padding<\/code>\u6216<code>border<\/code>\u503c\u8fdb\u884c\u4f4d\u7f6e\u4fee\u6b63\u3002\u4e8e\u662f\uff0c\u95ee\u9898\u6765\u4e86\uff0c\u6211\u4eec\u6ca1\u6cd5\u5355\u7eaf\u4f7f\u7528\u4e00\u4e2a\u516c\u7528\u7684\u7c7b\u540d\uff0c\u7c7b\u4f3c<code>.clearfix<\/code>\u8fd9\u6837\uff0c\u6574\u7ad9\u901a\u7528\u3002\u56e0\u4e3a\u4e0d\u540c\u81ea\u9002\u5e94\u573a\u666f\u7684\u7559\u767d\u8ddd\u79bb\u662f\u4e0d\u4e00\u6837\u7684\u3002<\/p>\n<p>\u6b64\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u5757\u72b6\u5143\u7d20\u7684BFC\u7279\u5b9a\u5b9e\u73b0\u66f4\u5f3a\u5927\u66f4\u667a\u80fd\u7684\u591a\u680f\u81ea\u9002\u5e94\u5e03\u5c40\uff08\u672c\u6587\u91cd\u70b9\uff09\u3002<\/p>\n<h3>\u4e09\u3001\u5143\u7d20\u7684BFC\u7279\u6027\u4e0e\u81ea\u9002\u5e94\u5e03\u5c40<\/h3>\n<p><strong>1. BFC\u5143\u7d20\u7b80\u4ecb\u4e0e\u57fa\u672c\u8868\u73b0<\/strong><br \/>\nBFC\u5168\u79f0&#8221;Block Formatting Context&#8221;, \u4e2d\u6587\u4e3a\u201c\u5757\u7ea7\u683c\u5f0f\u5316\u4e0a\u4e0b\u6587\u201d\u3002\u556a\u5566\u556a\u5566\u7279\u6027\u4ec0\u4e48\u7684\uff0c\u4e00\u8a00\u96be\u5c3d\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u53bb\u67e5\u627e\uff0c\u6211\u8fd9\u91cc\u4e0d\u8be6\u8ff0\uff0c\u514d\u5f97\u4e71\u4e86\u4e3b\u6b21\uff0c\u603b\u4e4b\uff0c\u8bb0\u4f4f\u8fd9\u4e48\u4e00\u53e5\u8bdd\uff1aBFC\u5143\u7d20\u7279\u6027\u8868\u73b0\u539f\u5219\u5c31\u662f\uff0c\u5185\u90e8\u5b50\u5143\u7d20\u518d\u600e\u4e48\u7ffb\u6c5f\u5012\u6d77\uff0c\u7ffb\u4e91\u8986\u96e8\u90fd\u4e0d\u4f1a\u5f71\u54cd\u5916\u90e8\u7684\u5143\u7d20\u3002\u6240\u4ee5\uff0c\u907f\u514dmargin\u7a7f\u900f\u554a\uff0c\u6e05\u9664\u6d6e\u52a8\u4ec0\u4e48\u7684\u4e5f\u597d\u7406\u89e3\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/inner-outer.png\" width=\"672\" height=\"312\" alt=\"\u62b1\u8bc8\uff08\u548c\u8c10\uff09\u4e0e\u9493\u9c7c\" class=\"imgpad mt10\" \/><\/p>\n<p>\u4ec0\u4e48\u65f6\u5019\u4f1a\u89e6\u53d1BFC\u5462\uff1f\u5e38\u89c1\u7684\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><code>float<\/code>\u7684\u503c\u4e0d\u4e3a<code>none<\/code>\u3002<\/li>\n<li><code>overflow<\/code>\u7684\u503c\u4e3a<code>auto<\/code>,<code>scroll<\/code>\u6216<code>hidden<\/code>\u3002<\/li>\n<li><code>display<\/code>\u7684\u503c\u4e3a<code>table-cell<\/code>, <code>table-caption<\/code>, <code>inline-block<\/code>\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u3002<\/li>\n<li><code>position<\/code>\u7684\u503c\u4e0d\u4e3a<code>relative<\/code>\u548c<code>static<\/code>\u3002<\/li>\n<\/ul>\n<p>BFC\u7279\u6027\u5f88\u591a\uff0c\u800c\u6211\u4eec\u8fd9\u91cc\uff0c\u53ea\u5173\u5fc3\u4e00\u4e2a\uff0c\u548c<code>float<\/code>\u5143\u7d20\u505a\u76f8\u90bb\u5144\u5f1f\u65f6\u5019\u7684\u8868\u73b0\u3002<\/p>\n<p>\u5982\u679c\u662f\u4e0a\u9762\u4ecb\u7ecd\u7684\u6d41\u4f53\u7279\u6027<code>div<\/code>, \u5f53\u5176\u548c\u6d6e\u52a8\u5143\u7d20\u5f53\u5144\u5f1f\u7684\u65f6\u5019\uff0c\u662f\u8986\u76d6\u7684\u5173\u7cfb\uff08\u53ef\u4ee5\u8111\u8865\u4e0b\u6587\u5b57\u73af\u7ed5\u56fe\u7247\u6548\u679c\uff09\u3002\u4f46\u662f\uff0c\u5143\u7d20BFC\u5316\u540e\uff0c\u672c\u7740\u201c\u91cc\u9762\u60ca\u5929\u62b1\u8bc8\uff08\u548c\u8c10\uff09\u70b8\u6210\u9b3c\uff0c\u5916\u9762\u4f9d\u7136\u6cf0\u7136\u9493\u5927\u9c7c\u201d\u7684\u539f\u5219\uff0c\u81ea\u7136\u662f\u4e0d\u4f1a\u4e0e\u6d6e\u52a8\u91cd\u53e0\u7684\uff08\u4f60\u60f3\u554a\uff0c\u8981\u662f\u51fa\u6765\u4e2a<code>clear:both<\/code>\u8fd8\u4e0d\u8ddf\u5916\u9762\u6d6e\u52a8\u5e72\u4e0a\u4e00\u67b6\u554a\uff09\uff0c\u56e0\u6b64\uff0c\u5757\u72b6\u76f8\u90bb\uff0c\u70b9\u51fb\u4e0b\u9762\u6309\u94ae\u611f\u53d7\u4e0b\u3002<br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/flow-to-bfc.html\" width=\"100%\" height=\"180\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u4f1a\u53d1\u73b0\uff0c\u666e\u901a\u6d41\u4f53\u5143\u7d20BFC\u540e\uff0c\u4e3a\u4e86\u548c\u6d6e\u52a8\u5143\u7d20\u4e0d\u4ea7\u751f\u4efb\u4f55\u4ea4\u96c6\uff0c\u987a\u7740\u6d6e\u52a8\u8fb9\u7f18\u5f62\u6210\u81ea\u5df1\u7684\u5c01\u95ed\u4e0a\u4e0b\u6587\u3002\u5982\u4e0b\u622a\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/2015-02-10_003132.png\" width=\"438\" height=\"165\" alt=\"BFC\u4e0e\u6d6e\u52a8\u8fb9\u7f18\u5bf9\u9f50~\" class=\"alignnone\" \/><\/p>\n<p>\u540c\u65f6\uff0c<strong>\u5143\u7d20\u539f\u672c\u7684\u6d41\u4f53\u7279\u6027\u4f9d\u7136\u4fdd\u7559\u4e86<\/strong>\u3002\u54c8\uff0c\u8fd9\u4e2a\u5f88\u91cd\u8981\uff0c\u4e5f\u5c31\u662f\uff0c\u867d\u7136\u4e0d\u4e0e\u6d6e\u52a8\u4ea4\u96c6\uff0c\u81ea\u52a8\u9000\u907f\u6d6e\u52a8\u5143\u7d20\u5bbd\u5ea6\u7684\u8ddd\u79bb\uff0c\u4f46\uff0c\u672c\u8eab\u4f5c\u4e3a\u666e\u901a\u5143\u7d20\u7684\u6d41\u52a8\u6027\u4f9d\u7136\u5b58\u5728\uff0c\u53cd\u6620\u5728\u5e03\u5c40\u4e0a\u5c31\u662f\u81ea\u52a8\u586b\u6ee1\u9664\u53bb\u6d6e\u52a8\u5185\u5bb9\u4ee5\u5916\u7684\u5269\u4f59\u7a7a\u95f4\u3002\u54df\uff0c\u8fd9\u4e0d\u5c31\u662f\u81ea\u9002\u5e94\u5e03\u5c40\u561b\uff01\uff01<\/p>\n<p><strong>2. BFC\u81ea\u9002\u5e94\u5e03\u5c40\u6a21\u5757\u95f4\u7684\u95f4\u8ddd<\/strong><br \/>\n\u7136\u800c\uff0c\u6a21\u5757\u8fc7\u4e8e\u4eb2\u5bc6\u63a5\u89e6\uff0c\u53ef\u80fd\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002\u4e00\u822c\u800c\u8a00\uff0c\u6211\u4eec\u9700\u8981\u4e00\u70b9\u95f4\u8ddd\u3002<\/p>\n<p>\u8bf4\u5230\u95f4\u8ddd\uff0c\u6211\u4eec\u7684\u7b2c\u4e00\u53cd\u5e94\u5c31\u662f<code>margin<\/code>. \u4e8e\u662f\uff0c\u6211\u4eec\u7ed9BFC\u5143\u7d20\u589e\u52a0\u4e00\u4e2a<code>margin-left:20px<\/code>, CSS\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    float: left;\r\n}\r\n.follow-content {\r\n    <span style=\"color:#cd0000;\">margin-left: 20px;<\/span>\r\n    background-color: #cad5eb;\r\n    overflow: hidden;\r\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u2026\u2026\u7eb3\u5c3c~ <img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/110.gif\" align=\"absmiddle\"> \u600e\u4e48\u8fd8\u662f\u50cf\u72d7\u5c41\u818f\u836f\u8d34\u5728\u4e00\u8d77\u554a\uff1f\uff1f<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/2015-02-12_001810.png\" width=\"432\" height=\"182\" alt=\"margin-left:20px\u65e0\u6548\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201502\/flow-to-bfc-margin.html\" class=\"a_link\" target=\"_blank\">BFC\u5143\u7d20\u589e\u52a0\u4e00\u4e2amargin\u65e0\u6548demo<\/a><\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u8fd9\u91cc\u7684<strong>margin\u5e76\u4e0d\u662f\u65e0\u6548\uff0c\u800c\u662f\u503c\u4e0d\u591f\u5927<\/strong>\uff0c\u97ad\u957f\u83ab\u53ca\u554a\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/bianchangmoji.jpg\" width=\"300\" height=\"164\" alt=\"\u6715\u771f\u662f\u97ad\u957f\u83ab\u53ca\" class=\"alignnone\" \/><\/p>\n<p>\u7528\u4e00\u4e2a\u5f62\u8c61\u7684Gif\u8868\u793a\u5c31\u662f\u4e0b\u9762\u8fd9\u6837\uff08\u70b9\u51fb\u64ad\u653e-468K\uff09\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201910\/kick-girl.jpg\" width=\"180\" height=\"200\" alt=\"\u5973\u751f\u62f3\u6253\u811a\u8e22\u591f\u4e0d\u5230\u7537\u5b69\" onclick=\"this.src=this.src.replace('.jpg','.gif')\" class=\"alignnone\" \/><\/p>\n<p>\u5de6\u4fa7\u6d6e\u52a8\u7684\u56fe\u7247\u5c31\u597d\u6bd4\u4e0a\u9762Gif\u56fe\u7247\u4e2d\u7537\u5b69\u7684\u80f3\u818a\uff0c\u59b9\u5b50\u5c31\u662fBFC\u5143\u7d20\uff0c\u7ed3\u679c\u4e24\u4eba\u7d27\u5bc6\u63a5\u89e6\u3002\u7136\u540e\uff0c<code>margin-left<\/code>\u5c31\u662f\u59b9\u5b50\u7684\u80f3\u818a\u4e2a\u811a\uff0c\u867d\u7136\u4e5f\u7529\u51fa\u53bb\u4e86\uff0c\u53ef\u60dc\u957f\u5ea6\u6709\u9650\uff0c\u4e8e\u662f\uff0c\u6beb\u65e0\u5f71\u54cd\u3002<\/p>\n<p>\u5982\u679c\u6309\u7167\u4e0a\u9762\u7684\u89e3\u91ca\uff0c\u90a3\u6211\u4eec\u628a<code>margin-left:20px<\/code>\u6539\u6210<code>margin-left:150px<\/code>\u5c31\u5e94\u8be5\u6709\u95f4\u8ddd\u4e86\uff1f<img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/32.gif\" align=\"absmiddle\"> \u4e00\u8bd5\u4fbf\u77e5\uff01<\/p>\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    float: left;\r\n}\r\n.follow-content {\r\n    <span style=\"color:#cd0000;\">margin-left: 150px;<\/span>\r\n    background-color: #cad5eb;\r\n    overflow: hidden;\r\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\uff0c\u5f53\u5f53\u5f53\u5f53\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/2015-02-12_003900.png\" width=\"431\" height=\"179\" alt=\"margin\u503c\u5f88\u5927\u6536\u83b7\u7684\u95f4\u8ddd\" class=\"alignnone\" \/><\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u6211\u8fd9\u91cc\u4e3e<code>margin<\/code>\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u4e0d\u662f\u8ba9\u5927\u5bb6\u8fd9\u6837\u4f7f\u7528\uff0c\u53ea\u662f\u4e3a\u4e86\u8ba9\u5927\u5bb6\u53ef\u4ee5\u6df1\u5165\u7406\u89e3BFC\u5143\u7d20\u4e0e\u6d6e\u52a8\u5143\u7d20\u6df7\u6392\u7684\u7279\u6027\u8868\u73b0\u3002\u5b9e\u9645\u5f00\u53d1\uff0c\u6211\u4eec\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\u5bf9BFC\u5143\u7d20\u8bbe\u7f6e<code>margin<\/code>, \u56e0\u4e3a\u53c8\u56de\u5230\u4e86\u6d41\u4f53\u5e03\u5c40\uff0c\u660e\u660e\u662f\u56fa\u5b9a\u768415\u50cf\u7d20\u95f4\u8ddd\uff0c\u4f46\u662f\uff0c\u6bcf\u4e2a\u5e03\u5c40\u90fd\u8981\u5199\u4e00\u4e2a\u4e0d\u540c\u7684<code>margin<\/code>\u503c\uff0c\u5b8c\u5168\u6ca1\u6709\u91cd\u7528\u4ef7\u503c\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u95f4\u8ddd\u90e8\u5206\u7684\u9ad8\u6f6e\u6765\u4e86\uff01<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6d6e\u52a8\u5143\u7d20\u7684<code>margin-right<\/code>\u6216\u8005<code>padding-right<\/code>\u8f7b\u677e\u5b9e\u73b0\u95f4\u8ddd\u6548\u679c\u3002\u95f4\u8ddd\u662f<code>20<\/code>\u50cf\u7d20\uff0c\u76f4\u63a5\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    float: left;\r\n    <span style=\"color:#cd0000;\">margin-right: 20px;<\/span>\r\n}<\/pre>\n<\/div>\n<p>\u4e0e\u6d6e\u52a8\u5143\u7d20\u7684\u5bbd\u5ea6\u662f\u591a\u5c11\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb\u3002\u4e0d\u4ec5\u5982\u6b64\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528BFC\u5143\u7d20\u7684<code>padding-left<\/code>\u6491\u5f00\u95f4\u8ddd\uff08\u867d\u7136<code>margin-left<\/code>\u4f5c\u7528\u9e21\u808b\uff09\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u6211\u4eec\u53ef\u80fd\u5c31\u4f1a\u6709\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\r\n.l { float: left; }\r\n.ovh { overflow: hidden; }\r\n<\/pre>\n<\/div>\n<p>\u7684\u81ea\u9002\u5e94\u56fa\u5b9a\u642d\u914d\u3002\u518d\u914d\u5408<a href=\"https:\/\/github.com\/zhangxinxu\/zxx.lib.css\" target=\"_blank\">zxx.lib.css<\/a>CSS\u6837\u5f0f\u5e93\u7684<code>margin<\/code>\u548c<code>padding<\/code>\u5bb6\u65cf\uff0c\u5feb\u901f\u5e03\u5c40\u53ef\u8c13\u6240\u5411\u62ab\u9761\u3002<\/p>\n<p><strong>3. \u4e0e\u7eaf\u6d41\u4f53\u7279\u6027\u5e03\u5c40\u7684\u4f18\u52bf<\/strong><br \/>\nBFC\u81ea\u9002\u5e94\u5e03\u5c40\u4f18\u52bf\u6211\u603b\u7ed3\u4e86\u4e0b\u97622\u70b9\uff1a<\/p>\n<ol>\n<li>\u81ea\u9002\u5e94\u5185\u5bb9\u7531\u4e8e\u5c01\u95ed\uff0c\u66f4\u5065\u58ee\uff0c\u5bb9\u9519\u6027\u5f3a\u3002\u6bd4\u65b9\u8bf4\uff0c\u5185\u90e8<code>clear:both<\/code>\u4e0d\u4f1a\u4e0e\u5144\u5f1f<code>float<\/code>\u4ea7\u751f\u77db\u76fe\u3002\u800c\u7eaf\u6d41\u4f53\u5e03\u5c40\uff0c<code>clear:both<\/code>\u4f1a\u8ba9\u540e\u9762\u5185\u5bb9\u65e0\u6cd5\u548c<code>float<\/code>\u5143\u7d20\u5728\u4e00\u4e2a\u6c34\u5e73\u4e0a\uff0c\u4ea7\u751f\u5e03\u5c40\u95ee\u9898\u3002<\/li>\n<li>\u81ea\u9002\u5e94\u5185\u5bb9\u81ea\u52a8\u586b\u6ee1\u6d6e\u52a8\u4ee5\u4e3a\u533a\u57df\uff0c\u65e0\u9700\u5173\u5fc3\u6d6e\u52a8\u5143\u7d20\u5bbd\u5ea6\uff0c\u53ef\u4ee5\u6574\u7ad9\u5927\u89c4\u6a21\u5e94\u7528\u3002\u800c\u7eaf\u6d41\u4f53\u5e03\u5c40\uff0c\u9700\u8981\u5927\u5c0f\u4e0d\u786e\u5b9a\u7684<code>margin<\/code>\/<code>padding<\/code>\u7b49\u503c\u6491\u5f00\u5408\u9002\u95f4\u8ddd\uff0c\u65e0\u6cd5CSS\u7ec4\u4ef6\u5316\u3002<\/li>\n<\/ol>\n<p>\u5982\u4e0b\u6548\u679c\uff0c\u56fe\u7247\u80fd\u5927\u80fd\u5c0f\uff0c\u5e03\u5c40\u4f9d\u7136\u826f\u597d\uff1a<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.zhangxinxu.com\/study\/201502\/flow-to-bfc-animation.html\" width=\"400\" height=\"216\" frameborder=\"0\"><\/iframe><\/p>\n<p>\u800cCSS\u4ee3\u7801\u5c31\u662f\u975e\u5e38\u7b80\u5355\u7684\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    <span style=\"color:#cd0000;\">float: left;<\/span> margin-right: 20px; \r\n}\r\n.bfc-content {\r\n    <span style=\"color:#cd0000;\">overflow: hidden;<\/span> background-color: #beceeb;\r\n}<\/pre>\n<\/div>\n<p>\u53ef\u4ee5\u8bf4\uff0c\u6709\u4e86BFC\u81ea\u9002\u5e94\u5e03\u5c40\uff0c\u57fa\u672c\u4e0a\u6ca1\u6709\u4e86\u7eaf\u6d41\u4f53\u7279\u6027\u5e03\u5c40\u5b58\u5728\u7684\u4ef7\u503c\u3002\u7136\u800c\uff0c\u53ea\u662f\u7406\u8bba\u4e0a\u5982\u6b64\u3002\u5982\u679c\uff0cBFC\u81ea\u9002\u5e94\u5e03\u5c40\u771f\u90a3\u4e48\u540a\u70b8\u5929\uff0c\u90a3\u4e3a\u4f55\u5e76\u6ca1\u6709\u53e3\u53e3\u76f8\u4f20\u5462\uff1f<\/p>\n<p>\u90a3\u6211\u4eec\u5c31\u5f97\u8fdb\u4e00\u6b65\u6df1\u5165\u7406\u89e3\u4e86\u3002<\/p>\n<p><strong>4. BFC\u5143\u7d20\u5bb6\u65cf\u4e0e\u81ea\u9002\u5e94\u5e03\u5c40\u9762\u9762\u89c2<\/strong><br \/>\n\u7406\u8bba\u4e0a\uff0c\u4efb\u4f55BFC\u5143\u7d20\u548c\u6d6e\u52a8\u641e\u57fa\u7684\u65f6\u5019\uff0c\u90fd\u53ef\u4ee5\u5b9e\u73b0\u81ea\u52a8\u586b\u5145\u7684\u81ea\u9002\u5e94\u5e03\u5c40\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u7531\u4e8e\u7edd\u5927\u591a\u6570\u7684\u89e6\u53d1BFC\u7684\u5c5e\u6027\u81ea\u8eab\u6709\u4e00\u4e9b\u53e4\u602a\u7684\u7279\u6027\uff0c\u6240\u4ee5\uff0c\u5b9e\u9645\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u80fd\u517c\u987e\u6d41\u4f53\u7279\u6027\u548cBFC\u7279\u6027\u6765\u5b9e\u73b0\u65e0\u654c\u81ea\u9002\u5e94\u5e03\u5c40\u7684\u5c5e\u6027\u5e76\u4e0d\u591a\u3002\u4e0b\u9762\u6211\u4eec\u7275\u9a74\u905b\u9a6c\u4e00\u4e2a\u4e00\u4e2a\u7785\u7785\uff08\u7c7b\u4f3c\u884c\u4e3a\u4ec5\u51fa1\u4e2a\u4ee3\u8868\u793a\u610f\uff0c\u4f60\u61c2\u7684\uff0c\u5982<code>float:left\/right<\/code>\uff09\uff1a<\/p>\n<ol>\n<li><strong>float:left<\/strong> \u6d6e\u52a8\u5143\u7d20\u672c\u8eabBFC\u5316\uff0c\u7136\u800c\u6d6e\u52a8\u5143\u7d20\u6709\u7834\u574f\u6027\u548c\u5305\u88f9\u6027\uff0c\u5931\u53bb\u4e86\u5143\u7d20\u672c\u8eab\u7684\u6d41\u4f53\u81ea\u9002\u5e94\u6027\uff0c\u56e0\u6b64\uff0c\u65e0\u6cd5\u7528\u6765\u5b9e\u73b0\u81ea\u52a8\u586b\u6ee1\u5bb9\u5668\u7684\u81ea\u9002\u5e94\u5e03\u5c40\u3002\u4e0d\u8fc7\uff0c\u5176\u56e0\u517c\u5bb9\u6027\u8fd8\u7b97\u826f\u597d\uff0c\u4e0e\u5806\u79ef\u6728\u8fd9\u79cd\u73b0\u5b9e\u8ba4\u77e5\u5339\u914d\uff0c\u4e0a\u624b\u7b80\u5355\uff0c\u56e0\u6b64\u5728\u65e7\u65f6\u4ee3\u88ab\u5927\u8086\u4f7f\u7528\uff0c\u4e5f\u5c31\u662f\u5e38\u8bf4\u7684\u201c\u6d6e\u52a8\u5e03\u5c40\u201d\uff0c\u4e5f\u7b97\u9634\u5dee\u9633\u9519\u5f00\u521b\u4e86\u81ea\u5df1\u7684\u4e00\u5957\u5e03\u5c40\u3002<\/li>\n<li><strong>position:absolute<\/strong> \u8fd9\u4e2a\u8131\u79bb\u6587\u6863\u6d41\u6709\u4e9b\u4e25\u91cd\uff0c\u8fc7\u4e8e\u6e05\u9ad8\uff0c\u4e0d\u8ddf\u666e\u901a\u5c0f\u4f19\u4f34\u73a9\u800d\uff0c\u6211\u5c31\u4e0d\u8bf4\u4ec0\u4e48\u4e86\u2026\u2026<\/li>\n<li><strong>overflow:hidden<\/strong> \u8fd9\u4e2a\u8d85\u68d2\u7684\u54e6\uff01\u4e0d\u50cf\u6d6e\u52a8\u548c\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u73a9\u5f97\u6709\u70b9\u8fc7\u3002\u4e5f\u5c31\u662f\u6ea2\u51fa\u526a\u88c1\u4ec0\u4e48\u7684\uff0c\u672c\u8eab\u8fd8\u662f\u4e2a\u5f88\u666e\u901a\u7684\u5143\u7d20\u3002\u56e0\u6b64\uff0c\u5757\u72b6\u5143\u7d20\u7684\u6d41\u4f53\u7279\u6027\u4fdd\u5b58\u76f8\u5f53\u5b8c\u597d\uff0c\u9644\u4e0aBFC\u7684\u72ec\u7acb\u533a\u57df\u7279\u6027\uff0c\u53ef\u8c13\u5982\u864e\u6dfb\u7ffc\uff0c\u5b87\u5b99\u65e0\u654c\uff01\u54c8\u65e0\u8bf6\u74e6(However), \u5c31\u8ddf\u6e05\u9664\u6d6e\u52a8\uff1a\n<div class=\"zxx_code\">\n<pre>.clearfix { overflow: hidden; _zoom: 1; }<\/pre>\n<\/div>\n<p>\u4e00\u6837\u3002\u7531\u4e8e\u5f88\u591a\u573a\u666f\u6211\u4eec\u662f\u4e0d\u80fd<code>overflow:hidden<\/code>\u7684\uff0c\u56e0\u6b64\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u4e00\u4e2a\u901a\u7528CSS\u7c7b\u6574\u7ad9\u5927\u89c4\u6a21\u4f7f\u7528\u3002\u56e0\u6b64\uff0c<code>float+overflow<\/code>\u7684\u81ea\u9002\u5e94\u5e03\u5c40\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u5c40\u90e8\uff08\u4f60\u786e\u5b9a\u4e0d\u4f1a\u6709\u4ec0\u4e48\u88ab\u526a\u88c1\u7684\u60c5\u51b5\u4e0b\uff09\u5f88happy\u5730\u4f7f\u7528\u3002<\/li>\n<li><strong>display:inline-block<\/strong> CSS\u5c4a\u6700\u4f1f\u5927\u7684\u58f0\u660e\u4e4b\u4e00\uff0c\u4f46\u662f\uff0c\u5728\u8fd9\u91cc\uff0c\u5c31\u6709\u4e9b\u6349\u895f\u89c1\u8098\u4e86\u3002<code>display:inline-block<\/code>\u4f1a\u8ba9\u5143\u7d20\u5c3a\u5bf8\u5305\u88f9\u6536\u7f29\uff0c\u5b8c\u5168\u5c31\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684<code>block<\/code>\u6c34\u5e73\u7684\u6d41\u52a8\u7279\u6027\u3002\u5509\uff0c\u53ea\u80fd\u662f\u4e00\u58f0\u53f9\u6c14\u4e00\u67aa\u6bd9\u6389\u7684\u547d\uff01\u7136\u800c\uff0c\u5cf0\u56de\u8def\u8f6c\uff0c\u4e16\u4e8b\u96be\u6599\u3002\u5927\u5bb6\u5e94\u8be5\u77e5\u9053\uff0cIE6\/IE7\u6d4f\u89c8\u5668\u4e0b\uff0c<code>block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u8bbe\u7f6e<code>display:inline-block<\/code>\u5143\u7d20\u8fd8\u662f<code>block<\/code>\u6c34\u5e73\uff0c\u4e5f\u5c31\u662f\u8fd8\u662f\u4f1a\u81ea\u9002\u5e94\u5bb9\u5668\u7684\u53ef\u7528\u5bbd\u5ea6\u663e\u793a\u3002\u4e8e\u662f\uff0c\u6211\u4eec\u5c31\u9634\u5dee\u9633\u9519\u5f97\u5230\u4e00\u4e2a\u6bd4<code>overflow:hidden<\/code>\u66f4\u725b\u903c\u7684\u58f0\u660e\uff0c\u5373BFC\u7279\u6027\u52a0\u8eab\uff0c\u53c8\u6d41\u4f53\u7279\u6027\u4fdd\u7559\u3002\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    float: left;\r\n}\r\n.bfc-content {\r\n    display: inline-block;\r\n}<\/pre>\n<\/div>\n<p>\u5f53\u7136\uff0c<code>*zoom: 1<\/code>\u4e5f\u662f\u7c7b\u4f3c\u6548\u679c\uff0c\u4e0d\u8fc7\u53ea\u9002\u7528\u4e8e\u4f4e\u7ea7\u7684IE\u6d4f\u89c8\u5668\uff0c\u5982IE7~<\/li>\n<li><strong>display:table-cell<\/strong> \u8ba9\u5143\u7d20\u8868\u73b0\u5f97\u50cf\u5355\u5143\u683c\u4e00\u6837\uff0cIE8+\u4ee5\u4e0a\u6d4f\u89c8\u5668\u624d\u652f\u6301\u3002\u8ddf<code>display:inline-block<\/code>\u4e00\u6837\uff0c\u4f1a\u8ddf\u968f\u5185\u90e8\u5143\u7d20\u7684\u5bbd\u5ea6\u663e\u793a\uff0c\u770b\u6837\u5b50\u4e5f\u662f\u4e0d\u5408\u9002\u7684\u547d\u3002\u4f46\u662f\uff0c\u5355\u5143\u683c\u6709\u4e2a\u975e\u5e38\u795e\u5947\u7684\u7279\u6027\uff0c\u5c31\u662f\u4f60\u5bbd\u5ea6\u503c\u8bbe\u7f6e\u5730\u518d\u5927\uff0c\u5927\u5230\u897f\u4f2f\u5229\u4e9a\uff0c\u5b9e\u9645\u5bbd\u5ea6\u4e5f\u4e0d\u4f1a\u8d85\u8fc7\u8868\u683c\u5bb9\u5668\u7684\u5bbd\u5ea6\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/2015-02-12_224124.png\" width=\"249\" height=\"259\" alt=\"\u8868\u683c\u5355\u5143\u683c\u4e0d\u4f1a\u8d85\u51fa\u8868\u683c\u5bbd\u5ea6\u7279\u6027\" class=\"alignnone\" \/><\/p>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u6211\u4eec\u628a<code>display:table-cell<\/code>\u8fd9\u4e2aBFC\u5143\u7d20\u5bbd\u5ea6\u8bbe\u7f6e\u5f88\u5927\uff0c\u6bd4\u65b9\u8bf43000\u50cf\u7d20\u3002\u90a3\u5176\u5b9e\u5c31\u8ddf<code>block<\/code>\u6c34\u5e73\u5143\u7d20\u81ea\u52a8\u9002\u5e94\u5bb9\u5668\u7a7a\u95f4\u6548\u679c\u4e00\u6a21\u4e00\u6837\u4e86\u3002\u9664\u975e\u4f60\u7684\u5bb9\u5668\u5bbd\u5ea6\u8d85\u8fc73000\u50cf\u7d20\uff0c\u5b9e\u9645\u4e0a\uff0c\u4e00\u822cweb\u9875\u9762\u4e0d\u4f1a\u67093000\u50cf\u7d20\u5bbd\u7684\u6a21\u5757\u7684\u3002\u6240\u4ee5\uff0c\u8981\u662f\u4f60\u5b9e\u5728\u4e0d\u653e\u5fc3\uff0c\u8bbe\u4e2a<code>9999<\/code>\u50cf\u7d20\u503c\u597d\u4e86\uff01<\/p>\n<div class=\"zxx_code\">\n<pre>.float-left {\r\n    float: left;\r\n}\r\n.bfc-content {\r\n    display: table-cell; width: 9999px;\r\n}<\/pre>\n<\/div>\n<p>\u770b\u4e0a\u53bb\uff0c\u597d\u50cf\u8fd8\u4e0d\u9519\u3002\u4f46\u662f\uff0c\u8fd8\u662f\u6709\u4e24\u70b9\u5236\u7ea6\uff0c\u4e00\u662fIE8+\u4ee5\u4e0a\u6d4f\u89c8\u5668\u517c\u5bb9\uff0c\u6709\u4e9b\u82e6\u903c\u7684\u56e2\u961f\u8fd8\u8981\u7ba1IE6\uff1b\u4e8c\u662f\u5e94\u4ed8\u8fde\u7eed\u82f1\u6587\u5b57\u7b26\u6362\u884c\u6709\u4e9b\u5403\u529b\uff08\u53ef\u4ee5\u5d4c\u5957<code>table-layout:fixed<\/code>\u89e3\u51b3\uff09\u3002\u4f46\u662f\uff0c\u603b\u4f53\u6765\u770b\uff0c\u9002\u7528\u7684\u573a\u666f\u8981\u6bd4<code>overflow:hidden<\/code>\u5e7f\u535a\u5f88\u591a\u3002\n<\/li>\n<li><strong>display:table-row<\/strong> \u5bf9<code>width<\/code>\u65e0\u611f\uff0c\u65e0\u6cd5\u81ea\u9002\u5e94\u5269\u4f59\u5bb9\u5668\u7a7a\u95f4\u3002<\/li>\n<li><strong>display:table-caption<\/strong> \u4e00\u65e0\u662f\u5904\u2026\u2026\u8fd8\u6709\u5176\u4ed6\u58f0\u660e\u4e5f\u90fd\u662f\u4e00\u65e0\u662f\u5904\uff0c\u6211\u5c31\u4e0d\u5168\u90e8\u5c55\u5f00\u4e86\u2026\u2026<\/li>\n<\/ol>\n<p><strong>\u603b\u7ed3\uff1a<\/strong>\u6211\u4eec\u5bf9BFC\u58f0\u660e\u5bb6\u65cf\u5927\u81f4\u8fc7\u4e86\u4e00\u904d\uff0c\u80fd\u62c5\u4efb\u81ea\u9002\u5e94\u5e03\u5c40\u91cd\u4efb\u7684\u4e5f\u5c31\u662f\uff1a<\/p>\n<ol>\n<li><span style=\"display:inline-block;width:200px;\"><code>overflow:auto\/hidden<\/code><\/span> IE7+<\/li>\n<li><span style=\"display:inline-block;width:200px;\"><code>display:inline-block<\/code><\/span>  IE6\/IE7<\/li>\n<li><span style=\"display:inline-block;width:200px;\"><code>display:table-cell<\/code><\/span>   IE8+<\/li>\n<\/ol>\n<p>\u7531\u4e8eoverflow\u6709\u526a\u88c1\u548c\u51fa\u73b0\u6eda\u52a8\u6761\u7b49\u9690\u60a3\uff0c\u4e0d\u9002\u5408\u4f5c\u4e3a\u6574\u7ad9\u901a\u7528\u7c7b\uff0c\u4e8e\u662f\uff0c\u6700\u540e\uff0c\u7c7b\u4f3c\u6e05\u9664\u6d6e\u52a8\u7684\u901a\u7528\u7c7b\u8bed\u53e5\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.clearfix {\r\n    *zoom: 1;\r\n}\r\n.clearfix:after {\r\n    content: ''; display: table; clear: both;\r\n}<\/pre>\n<\/div>\n<p>\u4e24\u680f\u6216\u591a\u680f\u81ea\u9002\u5e94\u5e03\u5c40\u7684\u901a\u7528\u7c7b\u8bed\u53e5\u662f\uff08<code>block<\/code>\u6c34\u5e73\u6807\u7b7e\uff0c\u9700\u914d\u5408\u6d6e\u52a8\uff09\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\r\n.cell {\r\n    display: table-cell; width: 9999px;\r\n    *display: inline-block; *width: auto;\r\n}\r\n<\/pre>\n<\/div>\n<p>\u8fd9\u5c31\u662f<a href=\"https:\/\/github.com\/zhangxinxu\/zxx.lib.css\" target=\"_blank\">zxx.lib.css<\/a>CSS\u6837\u5f0f\u5e93\u4e2d<code>.cell<\/code>\u7684\u7531\u6765\uff01<\/p>\n<p>\u5f53\u7136\uff0c\u7531\u4e8e\u548c\u6d6e\u52a8\u5143\u7d20\u5408\u4f5c\uff0c\u6e05\u9664\u6d6e\u52a8\u8fd8\u662f\u8981\u7684\uff0c\u4e8e\u662f\uff0c\u5c31\u6709\u4e86<code>.fix<\/code> + <code>.l\/.r<\/code> + <code>.cell<\/code>\u7684\u65e0\u654c\u7ec4\u5408\uff0c\u53ef\u4ee5\u591a\u680f\uff0c\u4e5f\u53ef\u4ee5\u65e0\u9650\u5d4c\u5957\u3002<\/p>\n<p>\u5982\u679c\u662f\u5c40\u90e8\uff0c\u4e14\u786e\u8ba4\u5b89\u5168\uff1b\u6216\u6709\u8fde\u7eed\u82f1\u6587\u5b57\u7b26\u6362\u884c\u7684\u9690\u60a3\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>.fix<\/code> + <code>.l\/.r<\/code> + <code>.ovh<\/code>\u7684\u65e0\u654c\u7ec4\u5408\uff0c\u53ef\u4ee5\u591a\u680f\uff0c\u4e5f\u53ef\u4ee5\u65e0\u9650\u5d4c\u5957\u3002<\/p>\n<h3>\u56db\u3001\u7ed3\u675f\u4e4b\u8a00<\/h3>\n<p>\u4f30\u8ba1\u672c\u6587\u662f\u6625\u8282\u524d\u7684\u6700\u540e\u4e00\u7bc7\u6587\u7ae0\u4e86\uff0c\u5c0f\u751f\u5728\u8fd9\u91cc\u63d0\u524d\u795d\u5927\u5bb6\u300c\u7f8a\u5e74\u5feb\u4e50\u300d\u300c\u4e07\u4e8b\u5982\u610f\u300d\u300c\u4e8b\u4e1a\u84b8\u84b8\u65e5\u4e0a\u300d\uff01<\/p>\n<p>\u53e6\uff0c\u672c\u6587\u5185\u5bb9\u975e\u6743\u5a01\uff0c\u591a\u4e2a\u4eba\u7406\u89e3\u4e0e\u611f\u609f\uff0c\u4ec5\u4f9b\u53c2\u8003\u3002\u6b22\u8fce\u4ea4\u6d41\uff0c\u63d0\u51fa\u60a8\u7684\u771f\u77e5\u707c\u89c1\uff01<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\uff01<img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/14.gif\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=4588\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=4588<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=4588\" title=\"\u70b9\u51fb\u67e5\u770b\u672c\u6587\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201502\/bfc-layout-cover.jpg\" width=\"550\" height=\"170\" class=\"imgpad mb10\"><\/a><br \/>\n\u597d\u4e45\u6ca1\u5199\u7eaf\u7cb9CSS\u76f8\u5173\u77e5\u8bc6\u7684\u6587\u7ae0\u4e86\uff0c\u6240\u8c13\u65b0\u9896\u7684CSS3\u6280\u672f\u4e4b\u6d41\u5360\u636e\u4e86\u73b0\u5728\u534a\u58c1\u6c5f\u5c71\u3002\u672c\u6587\u5185\u5bb9\u8fd8\u662f\u6bd4\u8f83\u4f20\u7edf\uff0c\u7acb\u8db3\u57fa\u7840\uff0c\u6df1\u5165\u7406\u89e3\u3002\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u76f8\u5173\u4ece\u4e1a\u8005\u6709\u6240\u6210\u957f\u3002\u5982\u9898\uff0c\u672c\u6587\u7740\u91cd\u5206\u6790\u6d41\u4f53\u7279\u6027\u4e0b\u7684\u81ea\u9002\u5e94\u5e03\u5c40\u548cBFC\u7279\u6027\u4e0b\u7684\u81ea\u9002\u5e94\u5e03\u5c40\uff0cdemo\u3001\u622a\u56fe\u4ee5\u53ca\u6e90\u4ee3\u7801\u4e00\u4e2a\u90fd\u4e0d\u5c11\uff0c\u8010\u5fc3\u770b\u5b8c\uff0c\u76f8\u4fe1\u4f1a\u6709\u4e00\u756a\u6536\u83b7\u7684\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[978,578,674,45,69,519,231,33,979],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4588"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=4588"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4588\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}