2011-05-18 62 views
1

由于某种原因,我无法清除某个元素,只是为了让人困惑!我试试这个:浮动到右侧后无法清除元素

.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

+2

请使用jsfiddle.net :) /编辑:这里http://jsfiddle.net/rx7V2/ - 什么是这个例子错了吗? – Alp 2011-05-18 23:30:57

+0

你试图达到的目标很不明确。 – 2011-05-18 23:33:53

回答

1

试试这个从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; 
} 
1

您应该应用.clearfix类的元素。我想这是你想清除的#page-wrap。要应用.clearfix类该div,写:<div id="post-wrap" class="clearfix">