micro clearfix不起作用

Mon*_*ffy 1 html css layout clearfix

我在我的固定版面中使用nicolas gallagher的micro-clearfix.在我的布局中,绿色的页脚不会出现.这意味着clearfix无法正常工作

<div class="container">
    <aside class="al">
    </aside>
    <section class="content">

    </section>
    <aside class="ar">
    </aside>
    <footer class="cf">
    </footer>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.container {
    width: 500px;
    height: 400px;
    margin: 0 auto;
}
.al {
    background: red;
    width: 100px;
    height: 100px;
    float: left;
}
.content {
    float: left;
    width: 300px;
    height: 100px;
    background: black;
}
.ar {
    background: red;
    width: 100px;
    height: 100px;
    float: left;
}
footer {
    background: blue;
    width: 100%;
    height: 100px;
    background: green;
}
Run Code Online (Sandbox Code Playgroud)

和微清除

.cf:after, .cf:before {
    content: " ";
    display: table; 
}
.cf:after {
    clear: both;
}
.cf {
    *zoom: 1;
}
Run Code Online (Sandbox Code Playgroud)

DEMO

我究竟做错了什么.我该如何做这项工作.请有人帮帮我

thi*_*dot 5

您通常将clearfix应用于包含所有浮点数的元素.

但是,在这种情况下,最简单的解决方案是不使用clearfix来包含浮点数,而是使用clear: bothon footer:

http://jsfiddle.net/thirtydot/4NJ6v/3/

如果你真的想在这里使用clearfix,它将如下所示:

http://jsfiddle.net/thirtydot/4NJ6v/6/

如您所见,div必须添加额外的包装,这不是很好.