Skip to content

Instantly share code, notes, and snippets.

@FLasH3r
Last active November 23, 2016 12:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FLasH3r/6916789 to your computer and use it in GitHub Desktop.
Save FLasH3r/6916789 to your computer and use it in GitHub Desktop.
clearfix variations (with original source link)
/*
* source: http://nicolasgallagher.com/micro-clearfix-hack/
*/
.clearfix:before, .clearfix:after { content: " "; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
/*
* source: http://perishablepress.com/new-clearfix-hack/
*/
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-table; }
/* Hides from IE-mac \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* End hide from IE-mac */
/*
* source: http://perishablepress.com/new-clearfix-hack/
*/
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; }
*:first-child+html .clearfix { zoom: 1; }
/*
* source: http://nicolasgallagher.com/better-float-containment-in-ie/
*/
.nbfc {
overflow: hidden;
*zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif");
*zoom: 1;
}
/*
* source: http://www.webtoolkit.info/css-clearfix.html
*/
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
/*
* http://davidwalsh.name/css-clear-fix
*/
.clearfix:before, .clearfix:after {
content: "\0020";
display: block;
height: 0;
overflow: hidden;
}
.clearfix:after {
clear: both;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment