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

From blackwiki
Jump to navigation Jump to search
imported>Jonesey95
(→‎Deprecated usage: clean up references to examples that are gone)
imported>Jonesey95
(update docs after deprecated parameters removed)
Line 7: Line 7:
 
{{CSS3 multiple column layout}}
 
{{CSS3 multiple column layout}}
  
{{tl|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.
+
{{tl|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 and two-thirds points between two columns.
 
* The list content is either provided by the {{para|content}} parameter (which can be restrictive of what content is allowed; e.g., wiki markup like {{!}} must somehow be escaped), or terminated with {{tl|div col end}}. The {{tl|columns-list}} wrapper uses the parameter method for providing content (including its limitations).
 
* The list content is either provided by the {{para|content}} parameter (which can be restrictive of what content is allowed; e.g., wiki markup like {{!}} must somehow be escaped), or terminated with {{tl|div col end}}. The {{tl|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 ({{para|small|yes}}), place vertical lines parameter ("rules") between the columns ({{para|rules}}) and to add other custom styling parameter ({{para|style}}).
+
* The template system (family) also offers parameter options to set a smaller (90%) font-size parameter ({{para|small|yes}}), place vertical lines parameter ("rules") between the columns ({{para|rules}}) and to add other custom styling ({{para|style}}).
  
 
{{tl|Div col}} can create multiple columns in [[web browser]]s which support one of the following [[CSS]] properties:
 
{{tl|Div col}} can create multiple columns in [[web browser]]s which support one of the following [[CSS]] properties:
Line 16: Line 16:
 
* ''-webkit-column-count'' (for [[WebKit]]-based browsers such as [[Safari (web browser)|Safari]] and [[Google Chrome]])
 
* ''-webkit-column-count'' (for [[WebKit]]-based browsers such as [[Safari (web browser)|Safari]] and [[Google Chrome]])
 
   
 
   
 +
By default, the template creates columns that are 30em wide.
 +
 
==Usage==
 
==Usage==
There are six parameters for this template and their usage is described below.  
+
There are five parameters for this template; their usage is described below.  
; {{para|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 (typography)|em]], about the width of a capital "M", e.g, <code>colwidth=20em</code>
+
; {{para|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). Can be specified in any CSS unit, for instance in [[Em (typography)|em]], about the width of a capital "M", e.g., <code>colwidth=20em</code>. If no value is supplied, the template uses a default of 30em.
 
; {{para|rules}} : Adds vertical lines ("rules") between the columns if set to <code>yes</code> or some CSS styling (e.g. <code>1px dashed blue;</code>).  
 
; {{para|rules}} : Adds vertical lines ("rules") between the columns if set to <code>yes</code> or some CSS styling (e.g. <code>1px dashed blue;</code>).  
 
; {{para|gap}} : Specifies the space between the content of adjacent columns. Specified in any CSS unit, e.g, <code>gap=2em</code>. The default spacing (set by browser) is 1em.
 
; {{para|gap}} : Specifies the space between the content of adjacent columns. Specified in any CSS unit, e.g, <code>gap=2em</code>. The default spacing (set by browser) is 1em.
 
; {{para|style}} : [[Cascading Style Sheets|CSS styling]] to apply to the columns.
 
; {{para|style}} : [[Cascading Style Sheets|CSS styling]] to apply to the columns.
 
; {{para|content}} : content to apply to the columns.
 
; {{para|content}} : content to apply to the columns.
; {{s|{{para|cols}}}} {{nobold|or first unnamed parameter}} : Specifies the number of columns (default 2). ''(Now [[Deprecation|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|See also]] section below.''
 
  
 
==Examples==
 
==Examples==
  
 
===Usage of "colwidth" parameter===
 
===Usage of "colwidth" parameter===
Important: The usage of the previous parameter "cols" is deprecated. It is strongly recommended to not use now-[[Deprecation|deprecated]] "cols" parameter (please leave it blank) and instead use "colwidth" parameter. 
 
 
; Example with column width of 10em
 
; Example with column width of 10em
 
<pre>
 
<pre>
Line 53: Line 53:
 
* h
 
* h
 
{{Div col end}}
 
{{Div col end}}
 
 
  
 
===Usage of "rules" parameter===
 
===Usage of "rules" parameter===
Line 81: Line 79:
 
* h
 
* h
 
{{Div col end}}
 
{{Div col end}}
 
  
 
===Usage of "gap" parameter===
 
===Usage of "gap" parameter===
Line 108: Line 105:
 
* h
 
* h
 
{{Div col end}}
 
{{Div col end}}
 
  
 
===Usage of "small" parameter===
 
===Usage of "small" parameter===
Line 162: Line 158:
 
}}
 
}}
  
===Usage with multiple named parameters===
+
===Usage with multiple parameters===
When parameters are named in the template, they can be used in any order.  
+
Parameters can be used in any order.  
 
'''Example: '''
 
'''Example: '''
 
<pre>
 
<pre>
Line 212: Line 208:
 
* h
 
* h
 
{{Div col end}}
 
{{Div col end}}
 
  
 
; Example with column width of 20em
 
; Example with column width of 20em
Line 288: Line 283:
 
h
 
h
 
{{Div col end}}
 
{{Div col end}}
 
==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|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|See also]] section below.''<br/>
 
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.
 
  
 
==Tracking categories==
 
==Tracking categories==
*{{clc|Pages using div col with deprecated parameters}} (for use of {{para|cols}} and unnamed parameters)
 
 
*{{clc|Pages using div col with unknown parameters}} (for erroneous use of parameter names not documented here)
 
*{{clc|Pages using div col with unknown parameters}} (for erroneous use of parameter names not documented here)
  

Revision as of 15:15, 12 July 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 and 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 (|style=).

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

By default, the template creates columns that are 30em wide.

Usage

There are five parameters for this template; 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). Can be specified in any CSS unit, for instance in em, about the width of a capital "M", e.g., colwidth=20em. If no value is supplied, the template uses a default of 30em.
|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.

Examples

Usage of "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 parameters

Parameters 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

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?File:Dagger-14-plain.png
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}}

File:Dagger-14-plain.png 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" />