1. 在 post 编辑器中切换到 HTML 模式, 如图所示:
2. 我写了几行 HTML 加 CSS 的代码模板,有需要的同学可以 copy and paste 到你自己的 post 中, 然后再编辑。 先看效果:
Table Header 1 | Table Header 2 | Table Header 3 |
---|---|---|
line 1 col 1 | line 1 col 2 | line 1 col 3 |
line 2 col 1 | line 2 col 2 | line 2 col 3 |
line 3 col 1 | line 3 col 2 | line 3 col 3 |
line 4 col 1 | line 4 col 2 | line 4 col 3 |
代码在这里:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- begin styling section: do not edit the style section if you don't know CSS --> | |
<style type="text/css"> | |
.simpleTable table{ | |
border-collapse: collapse; | |
font: 10pt Verdana, Arial, Helvetica, sans-serif; | |
empty-cells: show; | |
} | |
.simpleTable table, .simpleTable th, .simpleTable td { | |
border: 1px solid #5777C0; | |
} | |
.simpleTable table caption { | |
font-size: 11pt; | |
font-weight: bold; | |
color: #5777C0; | |
} | |
.simpleTable th, .simpleTable td { | |
/*top and bottom 2px, right and left 5px*/ | |
padding: 2px 5px; | |
} | |
.simpleTable th { | |
white-space: nowrap; | |
background-color: #5777C0; | |
color: white; | |
} | |
.simpleTable tr:nth-child(odd){ background-color:#ffffff; } | |
.simpleTable tr:nth-child(even) { background-color:#d9e9f9; } | |
</style> | |
<!-- end styling section: do not edit the style section if you don't know CSS --> | |
<!-- begin content section: tr means table row, th means table header, td means table cell --> | |
<!-- edit the following template, fill your content into proper table cells--> | |
<div class="simpleTable"> | |
<table> | |
<caption>A Blogspot Table Caption</caption> | |
<tbody> | |
<tr> | |
<th>Table Header 1</th> | |
<th>Table Header 2</th> | |
<th>Table Header 3</th> | |
</tr> | |
<tr> | |
<td>line 1 col 1</td> | |
<td>line 1 col 2</td> | |
<td>line 1 col 3</td> | |
</tr> | |
<tr> | |
<td>line 2 col 1</td> | |
<td>line 2 col 2</td> | |
<td>line 2 col 3</td> | |
</tr> | |
<tr> | |
<td>line 3 col 1</td> | |
<td>line 3 col 2</td> | |
<td>line 3 col 3</td> | |
</tr> | |
<tr> | |
<td>line 4 col 1</td> | |
<td>line 4 col 2</td> | |
<td>line 4 col 3</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> |
复制上面代码框里的所有代码,贴到你要加入表格的地方就可以编辑了。
假如你事先有用 Microsoft Excel 或者别的软件编辑表格,整个表格可以作为 HTML 代码导出的, 然后粘贴到你的网志中,具体看这里。
假如你觉得额外启用 Excel 比较麻烦, 或者没有 Excel, 就用我上面的代码, 直接在 blogger 里面编辑。 小表格用我的模板很方便的。
下面一个实例:
Year | Rounds | Winner | Winner's vtes in final round | Winner's vote in first round |
---|---|---|---|---|
1946 | 1 | Enrico de Nicola | 78.6% | -- |
1947 | 1 | Enrico de Nicola | 94.0% | -- |
1948 | 4 | Luigi Einaudi | 59.5% | 2.3% |
1955 | 4 | Giovanni Gronchi | 79.0% | 3.7 |
上面的表格出处在这里。 代码如下:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- begin styling section: do not edit the style section if you don't know CSS --> | |
<style type="text/css"> | |
.simpleTable table{ | |
border-collapse: collapse; | |
font: 10pt Verdana, Arial, Helvetica, sans-serif; | |
empty-cells: show; | |
} | |
.simpleTable table, .simpleTable th, .simpleTable td { | |
border: 1px solid #5777C0; | |
} | |
.simpleTable th, .simpleTable td { | |
/*top and bottom 2px, right and left 5px*/ | |
padding: 2px 5px; | |
} | |
.simpleTable th { | |
white-space: nowrap; | |
background-color: #5777C0; | |
color: white; | |
} | |
.simpleTable tr:nth-child(odd){ background-color:#ffffff; } | |
.simpleTable tr:nth-child(even) { background-color:#d9e9f9; } | |
</style> | |
<!-- end styling section: do not edit the style section if you don't know CSS --> | |
<!-- begin content section: tr means table row, th means table header, td means table cell --> | |
<!-- edit the following template, fill your content into proper table cells--> | |
<div class="simpleTable"> | |
<table> | |
<caption>Statistics of Italian President Election (Partial)</caption> | |
<tbody> | |
<tr> | |
<th>Year</th> | |
<th>Rounds</th> | |
<th>Winner</th> | |
<th>Winner's vtes in final round</th> | |
<th>Winner's vote in first round</th> | |
</tr> | |
<tr> | |
<td>1946</td> | |
<td>1</td> | |
<td>Enrico de Nicola</td> | |
<td>78.6%</td> | |
<td>--</td> | |
</tr> | |
<tr> | |
<td>1947</td> | |
<td>1</td> | |
<td>Enrico de Nicola</td> | |
<td>94.0%</td> | |
<td>--</td> | |
</tr> | |
<tr> | |
<td>1948</td> | |
<td>4</td> | |
<td>Luigi Einaudi</td> | |
<td>59.5%</td> | |
<td>2.3%</td> | |
</tr> | |
<tr> | |
<td>1955</td> | |
<td>4</td> | |
<td>Giovanni Gronchi</td> | |
<td>79.0%</td> | |
<td>3.7</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> |
No comments:
Post a Comment