2009-06-03 103 views
5

當我使用固定寬度(IE 7)時,我無法讓colspan工作?爲什麼?!Colspan不適用於​​寬度設置? (IE7)

示例代碼:

<html> 
    <head> 
    <style> 
    .inputGroup td 
    { width:250px; }  
    </style> 
    </head> 
<body> 
<table class="inputGroup"> 
    <tr> 
    <td>cell1</td> 
    <td>cell2</td> 
    </tr> 
    <tr> 
    <td colspan="2">This should span two columns but it doesnt</td> 
    </tr> 
    <tr> 
    <td>cell1</td> 
    <td>cell2</td> 
    </tr> 
</table> 
</body> 
</html> 

幫助別人? :(

回答

7

它,但你有限的寬度。如果你想,嘗試創建一個名爲另一個階級「.doubleSpanInputGroup」什麼的寬度爲500,並設置類到跨越列。

如。

<html> 
    <head> 
    <style> 
    .inputGroup td 
    { width:250px; } 
    .inputGroup td.doubleInputGroup 
    { width:500px; } 
    </style> 
    </head> 
<body> 
<table class="inputGroup"> 
    <tr> 
    <td>cell1</td> 
    <td>cell2</td> 
    </tr> 
    <tr> 
    <td colspan="2" class="doubleInputGroup">This should span two columns but it doesnt</td> 
    </tr> 
    <tr> 
    <td>cell1</td> 
    <td>cell2</td> 
    </tr> 
</table> 
</body> 
</html> 

編輯:國產新風格更加等級森嚴

+0

哦,哇。謝謝,有時你只是看不到你面前的事情。 – Alex 2009-06-03 23:31:12

1

嘗試使該規則適用於tr代替td,使寬度500像素,而不是,因爲這樣的:

.inputGroup tr { width: 500px; } 

您遇到的問題是因爲您已將td的限制設置爲最多250像素寬,因此瀏覽器只是遵循您的指示。

0

一般方式:

table tr:first-child td:first-child{ width:86px; } 

如果這是唯一的寬度都第一列藉此寬度和列跨度在IE7將工作

0

我試圖合併單元格單元格的寬度設置爲auto,似乎在IE7/8/9中工作正常

.yourColSpanTD { width: auto !important; }