2011-05-18 67 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">