2011-07-25 71 views
1

我建立了一個HTML表:的Html建設問題

<table cellpadding="0" cellspacing="0" border="0" style="width:1000px" id="maintable"> 
    <thead> 
    <tr> 
     <th class="asc" width="30"><h3>ID</h3></th> 
     <th width="200"><h3>Name</h3></th> 
     <th width="200"><h3>Artist</h3></th> 
     <th width="150"><h3>Album</h3></th> 
     <th width="60"><h3>Time</h3></th>  
    </tr> 
    </thead>  
    <tr class="evenrw"> 
     <td class="evensl" align="center">i++</td> 
     <td align="left"><a href="link">link name</a></td> 
     <td align="left">name</td> 
     <td align="left">name</td> 
     <td align="center">name</td> 
    <tr> 
<table> 

的問題是,當我把東西一排,使整個表變得更大,反正是有使電池的height做大,而不是細胞的width

+0

嘗試強制使用CSS的寬度;這應該將內容推到一起,使細胞更高,以適應所有。 – Bojangles

+0

檢查這個問題的答案。 [字纏繞在一個HTML表] [1] [1]:http://stackoverflow.com/questions/1258416/word-wrap-in-a-html-table – Shoban

+0

但問題是,如果我有一個小文本,我只需要一行,但文本很長,我需要兩行此。 – MTA

回答

1

您將表格寬度設置爲1000px,將單個表格列設置爲總計約600px。表與寬度的有點混亂,所以刪除樣式=「1000像素」,而應該解決的問題

jsfiddle example

如果答案工作,請把它標記爲所選擇的答案:)

第二部分

要在表格上方添加橫幅,只需在表格上方添加另一個<div>即可。所以它會是

<div id="banner_or_something"> 
    <!-- INSERT BANNER CODE HERE--> 
</div> 
<table cellpadding="0" cellspacing="0" border="0" style="width:1000px" id="maintable"> 
    <!--TABLE CODE HERE--> 
</table> 
+0

並且如果我在表格的頂部需要與表格的寬度相同的橫幅? – MTA

+1

然後將其添加到上面的代碼中,以便我們可以處理所有代碼。 – LeeR

+0

你的旗幟有多寬?它是在桌子裏面,還是在桌子上面?是否低於或以上......如果高於這個值,那麼不是,但那是另一回事。能否請您提供一些更多的信息.​​... – LeeR

0

使用CSS div &類與td標籤將幫助你。 例如

.aaa td{ 
width:200px; 
/* all attributes you want*/ 
} 

我希望它會幫助你