2014-12-21 54 views
1

我有一個包含在一個小區中的另一小表的表:無法更改表格單元格的寬度

<table id="big" style='width: 100%'> 
<tr> 
    .. 
    <td>..</td> 
    .. 
</tr> 
<tr> 
    .. 
    <td style='width: 75px'> 
    <table style='width: 100%'> 
    <tr> 
     <td style='width: 33%'><select></select></td> 
     <td style='width: 33%'><select></select></td> 
     <td style='width: 33%'><select></select></td> 
    </tr> 
    </table> 
    </td> 
    .. 
</tr> 
</table> 

正如你所看到的,我有一個小桌子,應採取全外細胞。此表應該分爲1x3單元格,每個單元格包含一個選擇組合框。

現在內表總是需要比指定的寬度太大,破壞外表的GUI。

正如你所看到的,我試圖限制像素的外部單元格寬度,沒有任何成功。

enter image description here

+0

你試圖刪除'寬:從內表100%'? –

+0

是的,嘗試使用百分比和絕對像素值 –

+0

發佈的代碼與顯示的圖像不匹配。它是'select'元素中的東西(它們實際上並非如發佈的代碼中那樣空)或CSS設置導致單元格變寬。 –

回答

6

你需要指定fixed table layout尊重列的寬度,即使內容需要更多的空間:

table { 
    table-layout: fixed; 
} 
+0

僅將它添加到內表中並且完美地工作 –

+0

好,很高興它有所幫助。 – dfsq