Hoppa till innehållet

Mall:Multicol

Från Wikisource, det fria biblioteket.
[redigera] [rensa sidcachen] Dokumentation

Skapar tabeller med godtyckligt antal kolumner. (Mallen är kopierad från 2021-10-11.)

Usage

[redigera]

{{Multicol}} is used to start a multi-column section of a page. Between each block of column text insert {{Multicol-break}}, between each section (which will keep the same column spacing) add {{Multicol-section}} and close the last column with {{Multicol-end}}. For example:

 {{Multicol}}
 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-end}}

You can have any number of columns. Each column will be the same width, equally dividing the available horizontal space. Each column has a small right margin (20 pixels), creating a "gutter" that prevents text in one column from touching text in the column to its right. See franl's user page for examples of how this template can be used.

Alternative templates

[redigera]

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.

Parameters

[redigera]

This template has four optional parameters


Overall width

[redigera]

The overall width of the set of columns is set in {{multicol}} as the first parmeter. It can be an absolute value (e.g., 40em) or a percentage of the available page width (e.g., 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}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Alignment

[redigera]

The multi-column region is positioned on the left side of the containing block by default. To change this, adjust the "align" parameter in {{multicol}} to "center" or "right"

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

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Margins

[redigera]

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}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Line format

[redigera]

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}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Other style

[redigera]

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

Technical notes

[redigera]

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