float 的初衷仅仅是:文字环绕效果css
display: inline-block / table-cell
position: absolute / fixed / sticky
overflow: hidden / scrollwordpress
display: none
position: absolute / fixed / sticky布局
清除浮动spa
方法一:浮动底部插入 clear: both;code
.clearfix:after { content:''; display: block; height: 0; overflow: hidden; clear: both; } .clearfix { *zoom: 1 } // 只有 IE 认识的属性
.clearfix:after { content:''; display: table; clear: both; } .clearfix { *zoom: 1 }
核心代码: 左侧div: float: left; 右侧div: display: table-cell; width: 9999px; <---没错width就是 9999px // 兼容 IE *display: inline-block; *width: auto;
浮动与右侧尺寸固定的流体布局,DOM 和视图位置不一致orm
左侧div: margin-right: 100px; 右侧div: float: right;
浮动与右侧尺寸固定的流体布局,DOM 和视图位置同样blog
左侧div: width: 100%; float: left; 右侧div: width: 56px; float: left; margin-left: -56px; margin-left,等于右侧 div 自身的宽度 width: 56px, 向左偏移的过程当中也上移了