Difference between revisions of "Template:Div col/doc"

From blackwiki
Jump to navigation Jump to search
imported>Izno
(→‎Deprecated usage: remove other deprecated examples)
imported>Jonesey95
(→‎Deprecated usage: clean up references to examples that are gone)
Line 291: Line 291:
 
==Deprecated usage==
 
==Deprecated usage==
  
===Usage without parameters===
+
===Usage without parameters or with the cols= parameter===
''Usage of fixed column counts is deprecated, therefore this example should no longer be used as well. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
+
''Usage of fixed column counts is deprecated. The "colwidth" parameter is recommended instead. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
  
 
===Usage of parameters without naming the parameters===
 
===Usage of parameters without naming the parameters===
''Usage of fixed column counts is deprecated, therefore this example should no longer be used as well. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''
+
''Usage of unnamed parameters is deprecated. For a fixed number of columns, use a template from the [[#See also|See also]] section below.''<br/>
When parameters are not named, the template considers the first unnamed parameter to be "cols" and the second unnamed parameter to be "colwidth". Any additional unnamed parameters (e.g. third, fourth, fifth, etc. unnamed parameter) will be ignored by the template and will show an error message when previewing the page.
+
When parameters are not named, the template considers the first unnamed parameter to be the deprecated {{para|cols}} and the second unnamed parameter to be {{para|colwidth}}. Any additional unnamed parameters (e.g. third, fourth, fifth, etc. unnamed parameter) will be ignored by the template and will show an error message when previewing the page.
 
 
===Usage of "cols" parameter===
 
Important: Use of now-[[Deprecation|deprecated]] "cols" parameter (equivalent to the first unnamed parameter) is discouraged, leave it blank and instead use the "colwidth" parameter. For a fixed number of columns, use a template from the [[#See also|See also]] section below.
 
  
 
==Tracking categories==
 
==Tracking categories==

Revision as of 04:40, 28 June 2018

CSS3 multiple-column layout browser support
Property Internet
Explorer
Firefox Safari Chrome Opera
column-width
column-count
≥ 10
(2012)
≥ 1.5
(2005)
≥ 3
(2007)
≥ 1
(2008)
≥ 11.1
(2011)
columns ≥ 10
(2012)
≥ 9
(2011)
≥ 3
(2007)
≥ 1
(2008)
≥ 11.1
(2011)
break-before
break-after
break-inside
≥ 10
(2012)
≥ 65
(2019)
≥ 10
(2016)
≥ 65
(2016)
≥ 15
(2013)

{{Div col}} can be used to make a list into columns that wrap properly and compatibly with portable computer devices, esp. PAD operating systems and small screens. It automatically breaks the available space into equal spaces, meaning, for instance, that it is not necessary to work out the halfway point, or the one-third & two-thirds points between two columns.

  • The list content is either provided by the |content= parameter (which can be restrictive of what content is allowed; e.g., wiki markup like | must somehow be escaped), or terminated with {{div col end}}. The {{columns-list}} wrapper uses the parameter method for providing content (including its limitations).
  • The template system (family) also offers parameter options to set a smaller (90%) font-size parameter (|small=yes), place vertical lines parameter ("rules") between the columns (|rules=) and to add other custom styling parameter (|style=).

{{Div col}} can create multiple columns in web browsers which support one of the following CSS properties:

Usage

There are six parameters for this template and their usage is described below.

|colwidth= 
Specifies the minimum width of the columns and determines automatically the number of columns based on screen width (i.e. more columns will be shown on wider displays). Overrides cols. Can be specified in any CSS unit, for instance in em, about the width of a capital "M", e.g, colwidth=20em
|rules= 
Adds vertical lines ("rules") between the columns if set to yes or some CSS styling (e.g. 1px dashed blue;).
|gap= 
Specifies the space between the content of adjacent columns. Specified in any CSS unit, e.g, gap=2em. The default spacing (set by browser) is 1em.
|style= 
CSS styling to apply to the columns.
|content= 
content to apply to the columns.
Template:S or first unnamed parameter 
Specifies the number of columns (default 2). (Now deprecated, as colwidth, above, is better suited to flexible formatting for a variety of display screen sizes (from mobile phones, tablets, etc to widescreen cinema-style displays)). For a fixed number of columns, use a template from the See also section below.

Examples

Usage of "colwidth" parameter

Important: The usage of the previous parameter "cols" is deprecated. It is strongly recommended to not use now-deprecated "cols" parameter (please leave it blank) and instead use "colwidth" parameter.

Example with column width of 10em
{{div col|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Usage of "rules" parameter

Example
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Usage of "gap" parameter

Example
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Usage of "small" parameter

Example showing how setting "small" parameter to "yes" produces smaller font size
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage of "content" parameter

Example showing how to provide "content" parameter without using {{Div col end}}
{{Div col|colwidth=10em|content=
* a
* b
* c
* d
* e
* f
* g
* h
}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

Usage with multiple named parameters

When parameters are named in the template, they can be used in any order. Example:

{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

or

{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h

and exactly the same result below

  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h


Example with column width of 20em
{{div col|colwidth=20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example with column width of 30em
{{div col|colwidth=30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
produces
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
Example of how this template behaves if no bullets (generated by asterisk mark) are used.
{{div col|colwidth=10em}}
a
b
c
d
e
f
g
h
{{div col end}}
produces

a b c d e f g h

Deprecated usage

Usage without parameters or with the cols= parameter

Usage of fixed column counts is deprecated. The "colwidth" parameter is recommended instead. For a fixed number of columns, use a template from the See also section below.

Usage of parameters without naming the parameters

Usage of unnamed parameters is deprecated. For a fixed number of columns, use a template from the See also section below.
When parameters are not named, the template considers the first unnamed parameter to be the deprecated |cols= and the second unnamed parameter to be |colwidth=. Any additional unnamed parameters (e.g. third, fourth, fifth, etc. unnamed parameter) will be ignored by the template and will show an error message when previewing the page.

Tracking categories

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Div col

Breaks a list into columns. It automatically breaks each column to an equal space, so you do not manually have to find the half way point on two columns. The list is provided by |content= or closed with {{div col end}}.

Template parameters

ParameterDescriptionTypeStatus
colscols 1

Specifies the number of columns.

Default
2
Numberdeprecated
Column widthcolwidth 2

Specifies the width of columns, and determines dynamically the number of columns based on screen width; more columns will be shown on wider displays. This overrides the 'cols' setting.

Example
30em
Stringsuggested
Rulesrules

Produces vertical rules between the columns if set to yes.

Example
'yes' or '1px dashed blue'
Stringoptional
Gap sizegap

Specifies the space between the content of adjacent columns.

Example
2em
Stringoptional
CSS stylestyle

Specifies any custom styling.

Stringoptional
Contentcontent

Specifies the content to divide into columns

Stringoptional
Small fontsmall

Use a smaller font size (90%)

Default
no
Example
yes
Booleanoptional

Redirects


See also

Column-generating template families

<section begin="table" />

Family Type
Handles wiki
 table code?Script error: No such module "If empty".
Responsive/
Mobile suited
Start template Column divider End template
"Col" Table Yes Yes {{Col-begin}},
{{Col-begin-fixed}} or
{{Col-begin-small}}
{{Col-break}} or
{{Col-2}} .. {{Col-5}}
{{Col-end}}
"Col-float" CSS float Yes Yes {{Col-float}} {{Col-float-break}} {{Col-float-end}}
"Columns" Table No Yes {{Columns}}
"Columns-list" CSS columns Yes Yes {{Columns-list}} (wrapper)
"Columns-start" CSS float Yes Yes {{Columns-start}} {{Column}} {{Columns-end}}
"Flex columns" CSS flexbox Yes Yes {{Flex columns}}
"Div col" CSS columns Yes Yes {{Div col}} {{Div col end}}

Script error: No such module "If empty". I.e., can the columns handle the wiki markup {| | || |- |} used to create tables? If not, templates that produce these elements (such as {{(!}}, {{!}}, {{!!}}, {{!-}}, {{!)}}) or HTML tags (<table>...</table>, <tr>...</tr>, etc.) will need to be used instead.<section end="table" />