2010-01-28 181 views
0

我有這樣的代碼 代碼:IE7浮動DIV高度

<div id="container"> 
    <div id="products_content"> 
     <div id="products_page_header"> 
      <div id="products_page"> 
       <div class="post"> 
        <div class="entrytext"> 
         some text 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
    <div id="clear"> 
    </div> 
    <div id="siteinfo"> 
     <p> 
      some content 
     </p> 
    </div> 
</div> 

這個CSS:

代碼:

div#container { 
    margin: 0 auto; 
    width: 960px; 
    height: auto; 
    border-left: thin solid #6b5c57; 
    border-right: thin solid #6b5c57; 
} 


div#products_page_header { 
    width: 960px; 
    height: 50px; 
    background-image: url(images/products_page_header.png); 
    background-repeat: no-repeat; 
    margin: 10px 0 0 0; 
} 

div#products_page { 
    width: 950px; 
    float: right; 
    margin: 50px 0 0 0; 
} 

div.post { 
    float: right; 
    border: 1px solid #6b5c57; 
    width: 200px; 
    height: 350px; 
    margin: 10px; 
} 
div#siteinfo { 
    height: 280px; 
    position:relative; 
    background-image: url(images/footer.jpg); 
} 

的問題是它的工作除了IE7所有新的瀏覽器! 產品容器的高度不會工作和頁腳div重疊! 我該怎麼辦?

回答

1

罪魁禍首是#products_page_header CSS規則的height: 50px; ..

其內容是浮動的它之外,它不會拉伸,以適應他們..

+0

你可以建議的方式來解決這個問題? – kfiroo 2010-04-18 09:23:49

+1

@ kfiroo,如果你想要一個父元素展開來包含其浮動的孩子,它不能有一個固定的高度...將其設置爲自動.. – 2010-04-18 12:48:54

+0

謝謝,工作。 – kfiroo 2010-04-19 10:13:53