CSS表未正常工作
table {
width: 100%;
height: 310px;
margin: 10px;
}
.tabledata {
background-color: #123456;
color: white;
font-size: 15px;
text-align: center;
padding: 2px;
}
HTML
<table class="allmenus">
<tr>
<td class="tabledata" colspan="5" rowspan="2">general<br>information</td>
<td class="tabledata" colspan="3" rowspan="2">unit</td>
<td class="tabledata" colspan="2" rowspan="2">location</td>
</tr>
<tr>
</tr>
<tr>
<td class="tabledata" colspan="3" rowspan="2">activities</td>
<td class="tabledata" colspan="4" rowspan="2">future events</td>
<td class="tabledata" colspan="3" rowspan="4">contact<br>us</td>
</tr>
<tr>
</tr>
<tr>
<td class="tabledata" colspan="4">gallery</td>
<td class="tabledata" colspan="3" rowspan="2">Donate Blood</td>
</tr>
<tr>
<td class="tabledata" colspan="4">volunteer</td>
</tr>
</table>
你好,我想產生類似下面的表格:
我寫了上面的代碼來創建這個表。
我不明白哪裏出了問題!看看桌子,一切都搞砸了。任何人都可以告訴我這裏有什麼問題,我該怎麼辦?請忽略顏色。提前致謝。
您是否嘗試過不使用表爲您列出不佈局? –
只是一個簡單的參考:除非你想花費時間扭曲回到1998年,否則你真的不應該使用表格。因爲多種原因,CSS是一個更好的工具。在CSS佈局上查找一些教程 – nomistic
在您期望的輸出中,您有3個單元的列和2個位置的列。但是在你的表格中,你的單位有'colspan = 2',位置有'colspan = 3'。修復它們以匹配你想要的,它看起來應該是正確的。 – Barmar