模板:Table cell templates
{{{1|{{{text}}}}}} |
The templates in this series are designed to be used in a table to make a cell with text in that cell, with an appropriately colored background. They are commonly used in comparison tables.
For example, {{yes}}
makes a cell with a green background. The text in the cell is taken from the first parameter; {{yes|Sure}}
would output "Sure" otherwise it defaults to "Yes". Most templates allow authors to override the default text in this way, some require text put after the template call and some also need a vertical bar in between: {{table cell template}} text
or {{table cell template}} | text
. This information, the colors and default texts are found in the table below.
If you want to use other attributes for the table cells, e.g. colspan
or rowspan
, they need to be put before the template call and there must be no vertical bar |
in between them:
是 | 否 | 不適用 |
---|---|---|
是/否 |
... !{{Yes}} ||{{No}} ||rowspan=2 {{n/a}} |- |colspan=2 {{Yes-No}} ...
模板
[编辑]Code
[编辑]Common code to most if not all the templates in this series:
style="background: #abcdef; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|}}}" class="automatic table-automatic"| {{{1|text}}}
Code specific to this template:
style="background: white; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|}}}" class="Table cell templates table-Table cell templates"| {{{1|{{{text}}}}}}
To make a new table cell template you can use:
{{subst:Table cell templates|text= default text |bg= background color |class= a class name without prefix |align= standard horizontal alignment}}
You should leave out the align
parameter and often the class
parameter is unnecessary, too.
Add the new template to the table in the common documentation afterwards. Please consider reusing one of the other templates and please choose the color sensibly.
If you find a table cell template that does not take a parameter and you want to be able to change the text in the cell, do not duplicate the template! Instead, edit the template and change the text to a default parameter substitution. For example, if a template's text is Dropped
, change that to {{{1|Dropped}}}
.
style="background: #abcdef; color: black; vertical-align: middle; text-align: center; " class="automatic table-automatic"| text
TemplateData
[编辑]One of several templates for styling individual table cells with standard contents and colors.
参数 | 描述 | 类型 | 状态 | |
---|---|---|---|---|
text | 1 | text to be displayed instead of the default, if this doesn't work put the text after the template, possibly with a vertical bar | in between
| 单行文本 | 可选 |
horizontal align | align | text alignment inside the cell, either 'left', 'right', 'center' or 'justified'
| 单行文本 | 可选 |
style | style | a semicolon separated list of additional CSS rules to be applied to the table cell
| 单行文本 | 可选 |
background color | color | a valid CSS color value or name to override the standard the cell background, only available with some templates
| 单行文本 | 可选 |
See also
[编辑]- {{Change}} – calculates, displays and color-codes changes between two values
- {{BSD-lic}} – specialized redirect for {{free}}
- {{GPL-lic}} – specialized redirect for {{free}}
- {{LGPL-lic}} – specialized redirect for {{free}}
Notes
[编辑]- ↑ The HTML class of table cell templates may be referenced in a user stylesheet to change appearance.
- ^ 2.0 2.1 Does not take a parameter; the content should be placed after the template call, separated by a pipe (|) character.
上述文档嵌入自Template:Table cell templates/doc。 (编辑 | 历史) 编者可以在本模板的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。 本模板的子页面。 |