We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
默认状态: 元素自动从左往右, 从上往下排列
浮动的基本语法: float: left; --- 左浮动 float: right; --- 右浮动 float: inherit; --- 继承父元素的浮动属性 float: none; --- 不使用浮动
设置了float的元素对其他相邻元素造成影响, 需要使用clear清除浮动, clear只会影响自身, 不会对其他相邻元素造成影响
.box01 { width: 100px; height: 100px; background-color: red; color: green; float: left; clear: both; }
<div class="container"> <div class="box01">11111</div> <div class="box02">22222</div> <div class="box03">33333</div> <div class='clear'></div> </div> .clear { clear: both; // 元素本身没有设置浮动 }
zoom: 1; /*触发hasLayout兼容IE6、7*/ <div class="container"> <div class="box01">11111</div> <div class="box02">22222</div> <div class="box03">33333</div> <div class='clear'></div> </div> .container { ... overflow: hidden; zoom: 1; }
在浮动元素后, 添加了一个看不见的盒子 <div class="container clearfix"> <div class="box01">11111</div> <div class="box02">22222</div> <div class="box03">33333</div> </div> .clearfix:after { content: ''; display: block; height: 0; visibility: hidden; clear: both; zoom: 1; } .clearfix { zoom: 1; }
1.使用css3 :after 伪元素清除浮动 2.overflow: hidden 清除浮动
p, div, h1~h6, ol, ul, li, dl, dt, dd, form, hr
span, a, em, sup, sub, input, img, textarea
The text was updated successfully, but these errors were encountered:
253867843
No branches or pull requests
Float浮动
2-1.普通流介绍
2-2.浮动的基础知识
2-3.使用浮动后产生的问题
2-4.清除浮动(作用于自身)
2-5.清除浮动(解决父容器高度塌陷)
3-1.课程总结
块元素特性总结:
行内元素特性总结:
清除浮动的误区
(1) 2-10.清除浮动元素(自身)的浮动, 它不能解决父容器高度塌陷的问题.
(2) 2-11.清除浮动, 能够解决父容器高度塌陷的问题.
The text was updated successfully, but these errors were encountered: