您的位置:首页 > Web前端 > CSS

CSS clearfix

2015-07-03 09:49 525 查看
The problem happens when a floated element is within a container box, that element does not automatically force the container’s height adjust to the floated element. When an element is floated, its parent no longer contains it because the float is removed from the flow. You can use 2 methods to fix it:

{clear: both;}

clearfix

Once you understand what is happening, use the method below to “clearfix” it.

Source code for webtoolkit.clearfix.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

.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%;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: