模板:Aligned table/doc:修订间差异
来自康健生活
创建页面,内容为“The purpose is of this template is for generating simple tables in locations where standard table markup is either not possible, without significant u…” |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
The purpose is of this template is for generating simple tables in locations where [[Help:Table|standard table markup]] is either not possible, without significant use of the {{ | The purpose is of this template is for generating simple tables in locations where [[Help:Table|standard table markup]] is either not possible, without significant use of the <nowiki>{{!}}</nowiki> magic word (e.g., with a {{tl|sidebar}} template), or cumbersome (due to the repetitive use of specification of the same style statement in each row). This template should <u>not</u> be used to replace [[Help:Table|standard table markup]] in articles. This template is meant to be complementary to {{tl|infobox}} or {{tl|sidebar}}, and <u>not</u> a replacement for {{tl|infobox}} or {{tl|sidebar}}. | ||
A simpler method to include a table in a template that does not directly support table markup is to create the table in a sub-template using standard markup and transclude it. | A simpler method to include a table in a template that does not directly support table markup is to create the table in a sub-template using standard markup and transclude it. | ||
| 第61行: | 第61行: | ||
| fullwidth | | fullwidth | ||
| If set (to anything, "on", "true", "yes", etc.), ensures table spans entire width available. | |||
(Effect is to remove border-spacing and add width:100% to the table's styling.) | (Effect is to remove border-spacing and add width:100% to the table's styling.) | ||
| 第74行: | 第74行: | ||
| style | | style | ||
| [[CSS styling]] applied to the table. | | [[CSS styling]] applied to the table. | ||
| <code> | | <code>nowiki> |style=width:80%;background:transparent; </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| 第103行: | 第103行: | ||
| ''Not set'' | | ''Not set'' | ||
| | | colwidth | ||
| CSS width property of cell in column | | CSS width property of cell in column (or include "width:...;" in <kbd>colstyle</kbd>). | ||
| <code><nowiki> |col2width=9.0em |col3width=35%</nowiki></code> | | <code><nowiki> |col2width=9.0em |col3width=35%</nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| | | colclass | ||
| Classes added to cell in column | | Classes added to cell in column . | ||
| <code><nowiki> |col1class=navbox-group </nowiki></code> | | <code><nowiki> |col1class=navbox-group </nowiki></code> | ||
| '' Not set'' | | '' Not set'' | ||
| | | colalign | ||
| CSS text-align property (left | | CSS text-align property (left / right / center) of cell in column 's cell contents (or include "text-align:...;" in <kbd>colstyle</kbd>). | ||
| <code><nowiki> |col4align=right </nowiki></code> | | <code><nowiki> |col4align=right </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| | | colnowrap | ||
| If set (to anything, "on", "true", "yes", etc.) adds "white-space:nowrap;" to the CSS style of cell in column | | If set (to anything, "on", "true", "yes", etc.) adds "white-space:nowrap;" to the CSS style of cell in column (i.e., to prevent lines within its cells from wrapping; or include "nowrap" in <kbd>colclass</kbd> or "white-space:nowrap;" in <kbd>colstyle</kbd>). | ||
| <code><nowiki> |col5nowrap=on </nowiki></code> | | <code><nowiki> |col5nowrap=on </nowiki></code> | ||
| | | | ||
| | | colstyle | ||
| CSS style appended to cell in column | | CSS style appended to cell in column . | ||
| <code><nowiki> |col4style=font-style:italic; </nowiki></code> | | <code><nowiki> |col4style=font-style:italic; </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| | | colheader | ||
| If set (to any value), changes cells in column | | If set (to any value), changes cells in column to table headers (headings). | ||
| <code><nowiki> |col1header=on </nowiki></code> | | <code><nowiki> |col1header=on </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| 第151行: | 第151行: | ||
<!--------Cells---------> | <!--------Cells---------> | ||
| class{{var|R}}. | | class{{var|R}}. | ||
| Classes applied to cell in row {{var|R}}, column | | Classes applied to cell in row {{var|R}}, column . Overrides any other class attributions (<kbd>row{{var|R}}class</kbd>, <kbd>colclass</kbd>). | ||
| <code><nowiki> |class1.2=adr </nowiki></code> | | <code><nowiki> |class1.2=adr </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| style{{var|R}}. | | style{{var|R}}. | ||
| CSS styling applied to cell in row {{var|R}}, column | | CSS styling applied to cell in row {{var|R}}, column . Overrides any more general styling (<kbd>leftright</kbd>, <kbd>colalign</kbd>, <kbd>row{{var|R}}style</kbd>, etc). | ||
| <code><nowiki> |style5.3=text-align:right; </nowiki></code> | | <code><nowiki> |style5.3=text-align:right; </nowiki></code> | ||
| ''Not set'' | | ''Not set'' | ||
| ''Unnamed parameters'' | |||
| Each unnamed parameter is taken to be the next cell in the table, starting at the table's top left corner and working left to right from top to bottom. | | Each unnamed parameter is taken to be the next cell in the table, starting at the table's top left corner and working left to right from top to bottom. | ||
| <code>{{!}} Azerbaijan {{!}} Malta {{!}} Zaire</code> | | <code>{{!}} Azerbaijan {{!}} Malta {{!}} Zaire</code> | ||
2020年3月2日 (一) 17:29的最新版本
The purpose is of this template is for generating simple tables in locations where standard table markup is either not possible, without significant use of the {{!}} magic word (e.g., with a {{sidebar}} template), or cumbersome (due to the repetitive use of specification of the same style statement in each row). This template should not be used to replace standard table markup in articles. This template is meant to be complementary to {{infobox}} or {{sidebar}}, and not a replacement for {{infobox}} or {{sidebar}}.
A simpler method to include a table in a template that does not directly support table markup is to create the table in a sub-template using standard markup and transclude it.
Full syntax
For parameter explanations, see table below.
{{Aligned table
| cols =
| fullwidth =
| class =
| style =
| colwidth =
| leftright =
| rightleft =
| colstyle =
| rowstyle =
<!--for Cth column:-->
| colCwidth =
| colCclass =
| colCalign =
| colCstyle =
| colCnowrap =
<!--for Rth row:-->
| rowRclass =
| rowRstyle =
| rowRheader =
<!--for cell R,C:-->
| classR.C =
| styleR.C =
| (cell 1,1) | (cell 1,2) | ... | ...
| (cell 2,1) | (cell 2,2) | ... | ...
}}
Parameters
| Parameter | Description | Examples | Default |
|---|---|---|---|
| cols | Number of columns in the table. | |cols=4 | 2 |
| fullwidth | If set (to anything, "on", "true", "yes", etc.), ensures table spans entire width available. (Effect is to remove border-spacing and add width:100% to the table's styling.) | |fullwidth=on | Not set |
| class | CSS/HTML class/es applied to the table. | |class=wikitable |class=infobox | Not set |
| style | CSS styling applied to the table. | nowiki> | Not set |
| colwidth | Width of each column (or include "width:...;" in colstyle). | |colwidth=6.0em |colwidth=25% | Not set |
| colstyle | CSS styling prepended to the cell style for each column. | |colstyle=background:transparent; | Not set |
| rowstyle | CSS styling applied to each row. | |rowstyle=text-align:center; | vertical-align:top; |
| leftright | If set (to anything, "on", "true", "yes", etc.) is equivalent to |col1align=left and |col2align=right | |leftright=on | Not set |
| rightleft | If set (to anything, "on", "true", "yes", etc.) is equivalent to |col1align=right and |col2align=left | |rightleft=on | Not set |
| colwidth | CSS width property of cell in column (or include "width:...;" in colstyle). | |col2width=9.0em |col3width=35% | Not set |
| colclass | Classes added to cell in column . | |col1class=navbox-group | Not set |
| colalign | CSS text-align property (left / right / center) of cell in column 's cell contents (or include "text-align:...;" in colstyle). | |col4align=right | Not set |
| colnowrap | If set (to anything, "on", "true", "yes", etc.) adds "white-space:nowrap;" to the CSS style of cell in column (i.e., to prevent lines within its cells from wrapping; or include "nowrap" in colclass or "white-space:nowrap;" in colstyle). | |col5nowrap=on | |
| colstyle | CSS style appended to cell in column . | |col4style=font-style:italic; | Not set |
| colheader | If set (to any value), changes cells in column to table headers (headings). | |col1header=on | Not set |
| row模板:Varclass | Classes applied to row 模板:Var. | |row10class=navbox-abovebelow | Not set |
| row模板:Varstyle | CSS styling applied to row 模板:Var. | |row2style=font-weight:bold; | |
| row模板:Varheader | If set (to any value), changes cells in row 模板:Var to table headers (headings). | |row1header=on | Not set |
| class模板:Var. | Classes applied to cell in row 模板:Var, column . Overrides any other class attributions (row模板:Varclass, colclass). | |class1.2=adr | Not set |
| style模板:Var. | CSS styling applied to cell in row 模板:Var, column . Overrides any more general styling (leftright, colalign, row模板:Varstyle, etc). | |style5.3=text-align:right; | Not set |
| Unnamed parameters | Each unnamed parameter is taken to be the next cell in the table, starting at the table's top left corner and working left to right from top to bottom. | | Azerbaijan | Malta | Zaire | Not set |
Examples
{{Aligned table
|cols=3 |class=wikitable
| A | 1 | a
| B | 2 | b
}}
| A | 1 | a |
| B | 2 | b |
{{Aligned table
|cols=4 |class=wikitable
|col1align=center |col2align=center
|col3align=right |col4align=right
| AAA | aa | 123 | 12345
| B | bbbbb | 1234 | 2
}}
| AAA | aa | 123 | 12345 |
| B | bbbbb | 1234 | 2 |
{{Aligned table
|class=wikitable |style=width:20em;
|col1align=center |col2align=right
| AAA | 123
| B | 2
}}
| AAA | 123 |
| B | 2 |
{{Aligned table
|cols=3 |class=wikitable sortable
|row1header=y
| U | # | l
| A | 1 | a
| B | 2 | b
}}
| U | # | l |
|---|---|---|
| A | 1 | a |
| B | 2 | b |
{{Aligned table
|cols=3 |class=wikitable sortable
|row1header=y
| U | # | l
| A | 1 | a
| B | 2 | b
| | |
| C | 3 | c
}}
| U | # | l |
|---|---|---|
| A | 1 | a |
| B | 2 | b |
| C | 3 | c |