Markdown绘制表格
正常markdown语法:
| 表头 | 表头 | 表头 |
| -------- | -------- | -------- |
| 行1,列1 | 行1,列2 | 行1,列3 |
| 行2,列1 | 行2,列2 | 行2,列3 |
| 行3,列1 | 行3,列2 | 行3,列3 |
效果图:
表头 | 表头 | 表头 |
---|
行1,列1 | 行1,列2 | 行1,列3 |
行2,列1 | 行2,列2 | 行2,列3 |
行3,列1 | 行3,列2 | 行3,列3 |
但是无法进行单元格合并。不过可以内嵌HTML代码来实现:
<h4>单元格跨行跨列:</h4>
<table border="1" width="500px" cellspacing="10">
<tr>
<th align="left">表头(左对齐)</th>
<th align="center">表头(居中)</th>
<th align="right">表头(右对齐)</th>
</tr>
<tr>
<td>行1,列1</td>
<td>行1,列2</td>
<td>行1,列3</td>
</tr>
<tr>
<td colspan="2" align="center">合并行单元格</td>
<td>行2,列3</td>
</tr>
<tr>
<td rowspan="2" align="center">合并列单元格</td>
<td>行3,列2</td>
<td>行3,列3</td>
</tr>
<tr>
<td>行4,列2</th>
<td>行4,列3</td>
</tr>
</table>
效果图:
单元格跨行跨列:
表头(左对齐) | 表头(居中) | 表头(右对齐) |
---|
行1,列1 | 行1,列2 | 行1,列3 |
合并行单元格 | 行2,列3 |
合并列单元格 | 行3,列2 | 行3,列3 |
行4,列2 | 行4,列3 |