CSS web pages Experience: Web page cleaning floating



During the floating layout, most people know, where necessary, to float clear:

.
For example:





Some Content

Preview this code at this time, we will find the parent element of the outer float container, not shown.This is because the child elements were floating by, and out of document flow, leading to the parent element height is zero.

If the code is amended as:





Some Content


Note that more than a clean float of the code.This is a good habit of CSS code, but this method increases the unwanted elements.There is a better method to modify HTML code:





Some Content

Define CSS classes, the "floating clearance" of the control:




Code:
. Clearfix: after {
content: ".";
clear: both;
height: 0;
visibility: hidden;
display: block;
}
This is the treatment of Firefox, because Firefox support for generating elements, and all versions of IE do not support the generation of elements




. Clearfix {
display: inline-block;
}
/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware this isIE on the Mac browser on the handling of backup / bin / conf / data / log / maint / svn / tmp /
backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp html. clearfix {height: 1%;}
/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware this ison win IE browser on the handling of backup / bin / conf / data / log / maint / svn / tmp /
. Clearfix {display: block;}
/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware this ison the display: inline-block; modifications, reset to the block element * /
Even if the child elements will be found floating, the parent will be the float container is still surrounded by the highly adaptive.

margin-top clear element is reset to zero.