惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 深蓝--广州

AngularJs angular.identity和angular.noop详解 opacity与RGBA透明的区别 CSS3 Gradient javascript语言精粹 严格模式认识 Promise与Defer认识 使用javascript打开一个新页而不被浏览器屏蔽 关于浏览器缓存 ie6下js更新元素display:block后,仍然不显示的hack办法 jQuery jsonp无法捕获404、500状态错误 移动端开发问题整理 修改input的type属性 transform:rotate在手机上显示有锯齿的解决方案 javascript钩子机制 jQuery.validate 常用方法及注意问题 SWFObject推出2使用示例 .NET种Json时对单引号和特殊字符串的处理 自定义枚举类型注释属性,并在程序中获取 Python Win32 Extensions
css中clearfix清除浮动的用法及其原理示例介绍
深蓝--广州 · 2016-07-21 · via 博客园 - 深蓝--广州

clearfix的定义:

.clearfix:after {}{ 
content: "."; /**//*内容为“.”就是一个英文的句号而已。也可以不写。*/ 
display: block; /**//*加入的这个元素转换为块级元素。*/ 
clear: both; /**//*清除左右两边浮动。*/ 
visibility: hidden; /**//*可见度设为隐藏。注意它和display:none;是有区别的。visibility:hidden;仍然占据空间,只是看不到而已;*/ 
line-height: 0; /**//*行高为0;*/ 
height: 0; /**//*高度为0;*/ 
font-size:0; /**//*字体大小为0;*/ 
} 
.clearfix {}{ *zoom:1;} /**//*这是针对于IE6的,因为IE6不支持:after伪类,这个神奇的zoom:1让IE6的元素可以清除浮动来包裹内部元素。*/ 

.clearfix的原理: 

1、在IE6, 7下zoom: 1会触发hasLayout,从而使元素闭合内部的浮动。 

2、在标准浏览器下,.clearfix:after这个伪类会在应用到.clearfix的元素后面插入一个clear: both的块级元素,从而达到清除浮动的作用。 

3、在需要清除浮动的时候,只要写一个.clearfix就行了,然后在需要清浮动的元素中 添加clearfix类名就好了。