( 在高度塌陷的笔记中有 BFC 的内容: https://www.cnblogs.com/xiaoxuStudy/p/13222253.html#fourone )
目录:
例子:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> .div1{ border: 2px solid red; /* display: flow-root */; } .div2{ width: 100px; height: 200px; border: 4px solid green; float: left; } </style> </head> <body> <div class="div1"> <div class="div2"></div> </div> </body> </html>
未使用 display : flow-root 前,高度塌陷
使用 display : flow-root 后
例子:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> .div1{ width: 100px; height: 200px; border: 2px solid red; float: left; } .div2{ height: 200px; border: 4px solid green; } </style> </head> <body> <div class="div1"></div> <div class="div2"></div> </body> </html>
未使用 display : flow-root 前
使用 display : flow-root 后