2012-07-03 65 views
1

我有一張簡單的表格。設置HTML表格列寬

<table border="1" width="100%"> 
     <tr> 
       <th>Select</th> 
       <th>Name</th> 
       <th>Preview</th> 
     </tr> 

如何設置寬度,使選擇和預覽爲15px,名稱是剩餘寬度的剩餘部分?

回答

3

使用嘿,現在你可以在你的CSS定義爲這樣

的CSS

.some{ 
    width:15px; 
    } 

HTML

<table border="1" width="100%"> 
     <tr> 
       <th class="some">Select</th> 
       <th>Name</th> 
       <th class="some">Preview</th> 
     </tr> 
</table> 

現場演示 http://tinkerbin.com/n4Q1NOXW

+0

工程就像一個魅力!謝謝!! –

1
<table border="1" width="100%"> 
     <tr> 
       <th width="15">Select</th> 
       <th>Name</th> 
       <th width="15">Preview</th> 
     </tr> 
1

可以作爲

<table border="1" width="100%"> 
    <tr> 
     <th width="15px">Select</th> 
     <th>Name</th> 
     <th width="15px">Preview</th> 
    </tr> 
0
<table border="1px" width="100%"> 
    <tr> 
     <th width="15px">Select</th> 
     <th>Name</th> 
     <th width="15px">Preview</th> 
    </tr> 
</table>​​​​​​​​​​​​​​​​​​​​​ 

如果你要根據自己的體型在任何尺寸的屏幕預覽,使用「%」的大小來確定。例如

<table border="1px" width="100%"> 
    <tr> 
     <th width="15%">Select</th> 
     <th>Name</th> 
     <th width="15%">Preview</th> 
    </tr> 
</table>​​​​​​​​​​​​​​​​​​​​​