清除浮动 clear:both的原理
来源:互联网 发布:淘宝上的刷钻可靠吗 编辑:程序博客网 时间:2024/04/30 14:21
清除浮动的原理,就是给浮动元素留下足够的垂直外边距给浮动元素。
<
div
>
<
div
style
=
"float:left"
></
div
>
</
div
>
以上面这个为例:一般而言 ,有三种方式清除浮动:
第一:让外层元素也浮动,例如:
<
div
style
=
"float:left"
>
<
div
style
=
"float:left"
></
div
>
</
div
>
第二:给外层div的末尾添加一个元素,并利用此元素清除浮动。例如:
<
div
style
=
"clearfix"
>
<
div
style
=
"float:left"
></
div
>
</
div
>
content:".";
display:block;
visibility:hidden;
height:0;
clear:both;
}
.clearfix{display:inline-block}
.clearfix{display:block}
其中后面的两个 是为了兼容其他浏览器设置的。因为:after不是所有浏览器都支持的。
第三:利用 overflow属性。
<
div
style
=
"overflow:hidden"
>
<
div
style
=
"float:left"
></
div
>
</
div
>
0 0
- 清除浮动 clear:both的原理
- 清除浮动clear:both的应用详解
- 清除浮动“clear:both;”的应用
- CSS clear both清除浮动
- CSS clear both清除浮动
- CSS clear both清除浮动
- clear:both样式清除浮动对它的影响
- 巧妙运用清除浮动clear:both
- DIV+CSS clear both清除产生浮动
- css Clear:both 清除float浮动
- DIV+CSS clear both清除产生浮动
- CSS 浮动(float:left),清除浮动(clear:both)
- [HTML]DIV+CSS clear both清除产生浮动
- 清除浮动clear-left-right-both-none效果
- float 浮动 《1》clear:both清除浮动 ;《2》设置父元素overflow:hidden来清除浮动
- CSS清除浮动_清除float浮——详解overflow:hidden 与clear:both属性
- 关于 clear:both 清楚浮动
- CSS清除浮动常用方法小结 CSS clear both {overflow:auto;zoom:1;}
- 文件路径中的‘/’‘\’的区别
- 编译器护眼界面参数
- getResources().getDimension(R.dimen.xsmall_text_size) 与 setTextSize(16)区别
- App设计的四项基本原则:用户都属猴
- MySQL在服务端的连接断掉解决方法
- 清除浮动 clear:both的原理
- Idea 快捷键
- Gas Station
- 音视频录入的pts和dts问题
- HDU 1598 find the most comfortable road(并查集+枚举)
- JQuery 从右侧向左滑动
- 算法学习
- HDOJ 题目2037今年暑假不AC(贪心)
- PHP压测优化