Help:使用維基標記式語言增修表格/5
一般而言,我們建議表格僅以維基百科的預設格式設定即可。然而在部分情況下,您會需要使用更複雜的格式,這些格式可由CSS來進行實作。每個表格格子的呈現方式都在格子內容之前增加style=" " |
來加以控制。CSS formatting is added to headings and captions in the same way.
對於格子內容| style="" | R1C1 | style="" | R1C2 | style="" | R1C3
|
|
對於表頭! style="" | 表頭C1 ! style="" | 表頭C2 ! style="" | 表頭C3
|
Any CSS attributes can be added in the style=" " |
.
屬性 | 意義 | 範例 |
---|---|---|
background | 填滿背景與指定背景顏色 | background:yellow
|
color | 文字顏色 | color:blue
|
width | 格子寬度 | width:100px
|
border-width | 邊界寬度 | border-width:3px
|
text-align | 格子內的文字排列 | text-align:center
|
As an example, here's an example with some varied formatting added to specific cells
{| class="wikitable" |+ Caption: some cells yellow. |- ! Header1 ! Header2 ! Header3 |- | style="background: yellow" | R1C1 | R1C2 | style="background: yellow" | R1C3 |- | R2C1 | style="background: yellow" | R2C2 | R2C3 |}
Then it would produce this:
表頭1 | 表頭2 | 表頭3 |
---|---|---|
R1C1 | R1C2 | R1C3 |
R2C1 | R2C2 | R2C3 |
CSS attributes can be added to the whole table by editing the first line of the table using {| style=" "
in the first line. Similarly, attributes can be added to a row using |- style=" "
The example below would fill the whole table yellow.
{| class="wikitable" style="background: yellow"
All of these formatting options should be used sparingly. Tables in crazy colours are hard to read.
隱藏式註解
In complicated tables, sometimes hidden comments can be useful to explain formatting. These hidden comments are only visible when editing the page, not when reading it normally. Comments can be added by placing them between <!--
and -->
.
| R1C1 || R1C2 ||R1C3 <!-- Hidden comment to explain this row -->