模板:Table alignment/doc

来自决策链云智库
< 模板:Table alignment
Zeroclanzhang讨论 | 贡献2024年1月18日 (四) 00:45的版本 (创建页面,内容为“{{Documentation subpage}} {{TemplateStyles|Template:Table alignment/tables.css}} == Purpose == To make it simpler to align the columns in tables with less wikicode. == Usage == Place <code><nowiki>{{Table alignment}}</nowiki></code> just before the table and then add some classes to the table. {| class="wikitable" ! classname ! Purpose |- | <code>defaultleft</code> || Align all table cells left by default |- | <code>defaultcenter</code> || Align all table ce…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

Lua错误 在模块:TNT的第167行:Missing Commons dataset I18n/Module:TNT.tab

Purpose

To make it simpler to align the columns in tables with less wikicode.

Usage

Place {{Table alignment}} just before the table and then add some classes to the table.

classname Purpose
defaultleft Align all table cells left by default
defaultcenter Align all table cells center by default
defaultright Align all table cells right by default
colNleft Align the cells in column N left, where N is a number
colNcenter Align the cells in column N center, where N is a number
colNright Align the cells in column N right, where N is a number

With the wikitable class the header cell content is always centered unless individually adjusted.

The col and default classes never effect the header cells (column, row, or anywhere) if the wikitable class is used. The col class overrides the default class.

If the wikitable class is not used, then col and default effect header cells.

Limitations

  • Column numbers up to col19 are supported. A table can have more columns but they cannot be aligned with this method.
  • On tables using rowspan or colspan, using the classes may not work well on those rows because the alignment appears in wrong cells. Normal table code like style="text-align: left/center/right;"| cell content can be added to individual cells, both to get the wanted alignment and override unwanted alignment.

Example

{{Table alignment}}
{| class="wikitable defaultcenter col1left col4right"
!Item1
!Item2
!Item3
!Item4
|-
|AAAAAA
|100-200
|3-4
|53.43
|-
|BBB
|5-6
|7-8
|5563.35
|-
|CC
|9-10
|113-125
|322313.00
|}
Item1 Item2 Item3 Item4
AAAAAA 100-200 3-4 53.43
BBB 5-6 7-8 5563.35
CC 9-10 113-125 322313.00