實現如下表格
分析:
該表格為五行四列,其中頭部包括兩行,內容為兩行,最后一行為統計的內容;
??其中“名稱”、“2016-11-22”、“重量”、“單價”、“小計”、“蘋果”、“香蕉”、“總價”均加粗可視為標題,
??第一行中時間橫跨兩列,最后一行中“總價”橫跨三列;
??第一行的“名稱”豎跨兩行,最后一列中的“小計”豎跨兩行。
代碼內容
<table border="1">
<theader>
<tr>
<th rowspan="2">名稱</th>
<th colspan="2">2016-11-22</th>
<th rowspan="2">小計</th>
</tr>
<tr>
<th>重量</th>
<th>單價</th>
</tr>
</theader>
<tbody>
<tr>
<th>蘋果</th>
<td>3公斤</td>
<td>5元/公斤</td>
<td>15元</td>
</tr>
<tr>
<th>香蕉</th>
<td>2公斤</td>
<td>6元/公斤</td>
<td>12元</td>
</tr>
</tbody>
<tfoot>
<th colspan="3">總價</th>
<td>27元</td>
</tfoot>
</table>
代碼分析:
通過colspan以及rowspan實現跨列和跨行;
??使用th標簽達到加粗的標題