定义:bfc就是符合一些特性的HTML标签,可以看做一个隔离的独立容器
bfc的作用:
- bfc可以避免外边距重叠
- 清除浮动
- 阻止元素被浮动元素覆盖
形成bfc的条件:
1.根元素:(<html>)
2.浮动元素(元素的float不是none)
3.绝对定位元素:(元素的osition 为absoluted或者 fixed)
4.display 为 inline - block 、 fable - cel 、 table - caption 、 table 、 table - row 、 table - row - group 、 table - header - group 、 table - footer - group 、 inline - table 、 flow - root 、 flex 或 inline - flex 、 grid 或 inline - grid
5. overflow 值不为 visible 的块元素
6 contain 值为 layout 、 content 或 paint 的元素
7.多列容器(元素的 column - count 或 column - width 不为 auto ,包括 column - count 为1)