Ways to clear float in css

There are ways to clear float in css, but I choose the following methods.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*********** simple method **************/
.clearfix:before, .clearfix:after {
content:"";
display:table;
}

.clearfix:after{
clear:both;
overflow:hidden;
}

.clearfix{
zoom:1;
}

/************ classic method ************/
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}

* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */

Tip: Add the class ‘clearfix’ to the parent element of the float elements.