模板:Multicol

维基文库,自由的图书馆
文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

用法[编辑]

{{Multicol}} 可在页面中做出分隔成多重栏位横向排列的段落。在每个栏位的文字之间插入 {{Multicol-break}},并且在栏位最后以 {{Multicol-end}} 作为结尾。例如:

 {{Multicol}}
 第一欄位中的文字.
 {{Multicol-break}}
 第二欄位中的文字.
 {{Multicol-break}}
 第三欄位中的文字.
 {{Multicol-end}}

栏位的数量没有上限。每一个栏位的宽度都会保持相同,依据页面宽度平均分类。每一个栏位右方预留了最少 20 pixels 宽的间隔,以避免不同栏位的文字看著像是连在一起。See franl's user page for examples of how this template can be used.

Alternative templates[编辑]

This template is only suitable when the content must be in exact columns and must always be side-by-side. This will cause the columns to be extremely narrow on small screens (a common phone size is around 23em across, which means a 2 column layout is only 11em per column and a 3 column layout less than 8em). If the exact break location is unimportant, use {{div col}}, which can automatically reduce column count on smaller screens. This is often more suitable for lists, where the exact line the new column starts is not important.

{{flex wrap centre}} is similar to this template in that the column break is fixed. However, that template will auto-wrap the "columns" into a vertical layout when the screen is too small to fit them side-by-side. This is often more suitable for images that appear side-by-side on paper.

参数[编辑]

这个模板有4个可选填的参数

  • {{{width}}}, {{{1}}}: 整个栏位组的宽度和栏位彼此之间的间隔宽度 (use auto to shrink to content)
  • {{{align}}}: Alignment of the overall set of columns
  • {{{line}}}: Interstitial line format.
  • {{{gap}}}, {{{2}}}: The width of the gutter


Overall width[编辑]

栏位组的整体宽度是 {{multicol}} 的第一个参数。可以是一个绝对值:例如 40em;也可以是依据整个页面宽度而定的百分比,例如 50%。 This parameter defaults to 100%. For example, to create a multi-column section that is only 50% the width of the page:

{{Multicol|50%}}
This text appears in the first column.
{{Multicol-break}}
This text appears in the second column.
{{Multicol-break}}
This text appears in the third column.
{{Multicol-section}}
This text appears in the next row, first column.
{{Multicol-break}}
This text appears in the next row, second column.
{{Multicol-end}}

Alignment[编辑]

多栏位的预设值是靠页面左方。要改变对其方向,adjust the "align" parameter in {{multicol}} to "center" or "right"

 {{Multicol|50%|align=center}}
 ...
 {{Multicol-end}}

Margins[编辑]

The margins can easily be changed by adjusting the second parameter in {{multicol}} or the first in {{multicol-break}}. You do not specify it in {{multicol-end}}. The margins occur on the left and right of the block, so you should specify half the actual separation you want.

{{Multicol||40px}}
This text appears in the first column.
{{Multicol-break|40px}}
This text appears in the second column.
{{Multicol-end}}

Line format[编辑]

The third parameter controls a line between the blocks. This parameter is named "line" and cannot be accessed using positional arguments. It must be specified in {{multicol}} and {{multicol-break}}. The line format is given in the CSS way, eg "1px solid black", "2px dashed red", etc.

{{Multicol|line=1px solid black}}
This text appears in the first column.
{{Multicol-break|line=1px solid black}}
This text appears in the second column.
{{Multicol-end}}

Other style[编辑]

the |style= parameter may be used to define other styles not covered above.

Technical notes[编辑]

This template uses a table to achieve the columns. Consider using a table if it is clearer in context than using this template.

See also[编辑]