2017-02-23 28 views
-1

沒有標題,我的表看起來很好,很正常。我嘗試添加一個表格標題,並將所有內容都排除在外。有誰能告訴我如何避免這種情況?爲什麼我的表格標題將表格行推得不合適?

相關代碼:

<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="white"> 
<th width="80%"> Let's talk about the wall </th> 
<tr> 
<td width="6%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td> 
<td width="75%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td> 
<td width="19%" align="center" bgcolor="white"><font face="arial"><strong></strong></font></td> 
</tr> 

然後:

<tr> 
<td bgcolor="white"><font face="arial"></font></td> 
<td bgcolor="white"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><font face="arial"><? echo $rows['topic']; ?></a><BR></font></td> 
<td align="center" bgcolor="white"><font face="arial"></font></td> 
</tr> 

Obviously mutated table

需要明確的是,你看到的文字,如 '測試', 'slaaa' 等 - 我希望它能夠更接近它所在位置的左邊,這就是我沒有標題的表格時所處的位置。

+0

你的標題爲一個單元,但在你的表的其餘部分,每排有三個單元。如果您希望標題覆蓋全部三列,請查看colspan屬性。 – j08691

回答

0

你缺少tr包裹thcolspan

th { 
 
    background: #ccc; 
 
} 
 

 
td { 
 
    background: #aaa; 
 
}
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="white"> 
 
<tr> 
 
    <th colspan="3"> Let's talk about the wall</th> 
 
</tr> 
 
<tr> 
 
    <td width="6%" align="center" bgcolor="white"> 
 
    <strong>some text</strong> 
 
    </td> 
 
    <td width="75%" align="center" bgcolor="white"> 
 
    <strong>Column 2</strong> 
 
    </td> 
 
    <td width="19%" align="center" bgcolor="white"> 
 
    <strong>Column 3</strong> 
 
    </td> 
 
</tr>

相關問題