2012-07-23 61 views
1

我遇到了一些與IE7和固定佈局和固定列大小的問題。大多數瀏覽器使用列的寬度來設置單元格的大小,包括填充,但IE7似乎將其設置爲排除填充,因此存在過度掛起。IE7 - 固定列寬度問題,當單元格有填充時

我搜索,搜索和搜索了一個解決方案,但我找不到任何東西,除了應用「框大小:邊框」的一切,這是不可能的。刪除「table-layout:fixed」也適用,但其他代碼依賴於此。

如何在瀏覽器之間獲得一致性?

<!-- DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" --> 
<html> 
    <head> 
    <style type="text/css"> 
     div { 
     width: 200px; 
     height: 10px; 
     background-color: blue; 
     } 
     table { 
     width: 200px; 
     border-collapse: collapse; 
     table-layout: fixed; 
     } 
     .first { 
     width: 50px; 
     background-color: green; 
     } 
     .second { 
     width: 150px; 
     background-color: red; 
     } 
     .alt { 
     padding: 10px; 
     } 
    </style> 
    </head> 
    <body> 
    <div></div> 
    <table> 
     <colgroup> 
     <col class="first" /> 
     <col class="second" /> 
     </colgroup> 
     <tr> 
     <td>Foo</td> 
     <td class="alt">bar</td> 
     </tr> 
    </table> 
    </body> 
</html> 

類似的問題:<col> width and padding - IE7

IE7 SS IE7 screenshot

IE9 SS IE9 SS

+0

您需要使用條件語句。 <! - [if IE 7]> IE7的特別說明在這裏 2012-07-25 03:38:26

回答

0

IE不`噸支撐臺填充。您需要將該緩衝區應用於表格數據單元。