.p{width:500px; border:1px solid black; padding:10px;}
.c{width:100px; height:100px; background-color: green;}
<div class="p">
<div class="c"></div>
<div class="c"></div>
<div class="c"></div>
<div style="clear:left;"></div>
</div>
.fix::after {
content:"";
display:table;
clear:both;
}
- 浮动 (元素的
float:
left; float: right; float: both;
) - 绝对定位元素 (元素的
position
为 absolute
或 fixed
) - 行内块 inline-blocks (元素的
display: inline-block
) - 表格单元格 (元素的
display: table-cell
,HTML表格单元格默认属性) - 表格标题 (元素的
display: table-caption
,HTML表格标题默认属性) overflow: hidden
的元素- 弹性盒子 flex boxes (元素的
display: flex
或 inline-flex
)