Skip to content

Instantly share code, notes, and snippets.

@HenryC-3
Last active January 4, 2023 04:37
Show Gist options
  • Save HenryC-3/7ffd38611425b279c56cc3927044d4c6 to your computer and use it in GitHub Desktop.
Save HenryC-3/7ffd38611425b279c56cc3927044d4c6 to your computer and use it in GitHub Desktop.
// 现代浏览器clearfix方案, 不支持IE6/7
.clearfix:after {
display: table;
content: " ";
clear: both;
}
// 全浏览器通用的clearfix方案
// 引入了zoom以支持IE6/7
.clearfix:after {
display: table;
content: " ";
clear: both;
}
.clearfix {
*zoom: 1;
}
// 全浏览器通用的clearfix方案【推荐】
// 引入了zoom以支持IE6/7
// 同时加入:before以解决现代浏览器上边距折叠的问题
.clearfix:before,
.clearfix:after {
display: table;
content: " ";
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment