html - 向右浮动后无法清除元素

标签 html css css-float

出于某种原因,我永远无法清除元素,这只会让人感到困惑!。我试试这个:

.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 */

到父元素,没有任何作用!真的很困惑:/

http://pastebin.com/qAGaCYbH

最佳答案

html5boilerplate.com 试试这个:

/* The Magnificent Clearfix: 
   Updated to prevent margin-collapsing on child elements. 
   j.mp/bestclearfix */

.clearfix:before, .clearfix:after { 
    content: "\0020"; 
    display: block; 
    height: 0; 
    overflow: hidden; 
}

.clearfix:after { 
    clear: both; 
}

/* Fix clearfix: 
   blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */

.clearfix { 
    zoom: 1; 
}

关于html - 向右浮动后无法清除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6052179/

相关文章:

CSS float 搞砸了

html - 使用经典 asp 读取 html 页面并将其插入数据库

html - 是否可以只为 <p> 而不是 <a> 元素设置不透明度?

html - CSS 中的动态和固定大小

html - 包含文本的 .svg 图像,Firefox 中缺少字体系列

CSS float 和重叠框

Javascript 函数未定义

javascript - 在更改不透明度时更改另一个 div 内可点击 div 的点击事件

html - 如何删除缩略图网格中的空白区域

css - 如何调整 block 元素的边界框以适应 float 元素?