Open main menu

EUSwiki β

Changes

Template:Div col/doc

9,825 bytes added, 17:10, 16 July 2016
Redirects: list the appropriate ones
<!-----------------------------------------------------------------------------
PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE
------------------------------------------------------------------------------>
{{Documentation subpage}}
{{Ombox |type=notice |text=Columns are not supported by some older browsers, most notably Internet Explorer 9 and below and Opera 11.0 and below. See [[Template:Reflist#Browser support for columns|this page]] for more information.}}
{{CSS3 multiple column layout}}

{{tl|Div col}}, together with {{tl|div col end}}, is used to make a list into columns. It automatically breaks each column into an equal space, meaning, for instance, it isn't necessary to work out the halfway point between two columns. The template 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}}).

{{tl|Div col}} can create multiple columns in [[web browser]]s which support one of the following [[CSS]] properties:
* ''column-count'' (for [[Cascading Style Sheets#CSS 3|CSS3]]-compliant browsers; see [http://www.w3.org/TR/css3-multicol/ CSS3 module: Multi-column layout])
* ''-moz-column-count'' (for [[Mozilla application framework|Mozilla]]/[[Gecko (layout engine)|Gecko]]-based browsers such as [[Firefox]])
* ''-webkit-column-count'' (for [[WebKit]]-based browsers such as [[Safari (web browser)|Safari]] and [[Google Chrome]])

==Usage==
There are five parameters for this template and their usage is described below.
; {{s|{{para|cols}}}} {{nobold|or first unnamed parameter}} : ''(Now [[Deprecation|deprecated]], as ''colwidth'' below is better suited to flexible formatting for a variety of display screen sizes (from mobile phones, tablets, etc to widescreen cinema-style displays))''<br/>Specifies the number of columns (default 2).
; {{para|colwidth}} {{nobold|or second unnamed parameter}} : 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''. 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|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|style}} : [[Cascading Style Sheets|CSS styling]] to apply to the columns.

==Examples==

===Usage without parameters===
Example with no parameters produces two columns as the default is two columns.
<pre>
{{Div col}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


===Usage with named parameters===
When parameters are named in the template, they can be used in any order.
; Example:
<pre>
{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
or
<pre>
{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|colwidth=10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
and exactly the same result below
{{Div col|rules=yes|gap=2em|small=yes|colwidth=10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


===Usage of parameters without naming the parameters===
When parameters are not named then template considers first unnamed parameter to be "col", second unnamed parameter to be "colwidth", remaining unnamed parameters (e.g. third, fourth, fifth, etc unnamed parameter) will be ignored by the template without providing an error message. The first and second parameter "col" and "colwidth" could be unnamed but all other parameters (such as "rules", "gap", "style" and "small") must always be named in the template.
;Example with correct usage of unnamed parameters
Note the empty column for the "number of columns" between "Div col" and "10em".
<pre>
{{div col||10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces
{{div col||10em|rules=yes|gap=2em|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


;Example with incorrect usage of unnamed parameters
Note that the unnamed third, fourth and fifth parameters will be ignored by the template. If used, then
third, fourth and fifth parameters must always be named.
<pre>
{{div col||10em|yes|2em|yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces (unnamed third, fourth and fifth parameters are ignored)
{{div col||10em|yes|2em|yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


===Usage of "col" parameter===
Important tip: Use of now-[[Deprecation|deprecated]] "col" parameter is discouraged, leave it blank and instead use the "colwidth" parameter.

; Example with 3 columns
<pre>
{{Div col|3}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|3}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

; Example with 4 columns
<pre>
{{Div col|4}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|4}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

===Usage of "colwidth" parameter===
Important tip: Most wiki reviewers will reject the usage of previous parameter "col" and instead they prefer the use of this "col width" parameter i.e. it is strongly recommended to not use now-[[Deprecation|deprecated]] "col" parameter (please leave it blank) and instead use "col width" parameter.
; Example with column width of 10em
<pre>
Note the empty column for the "number of columns" between "Div col" and "10em".
{{div col||10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col||10em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

; Example with column width of 20em
<pre>
{{div col||20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col||20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

; Example with column width of 30em
<pre>
{{div col||30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}
</pre>
; produces:
{{Div col||30em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

; Example of how this template behaves if no [[•|bullets]] (generated by asterisk mark) are used.
<pre>
{{div col||10em}}
a
b
c
d
e
f
g
h
{{div col end}}
</pre>
; produces:
{{Div col||10em}}
a
b
c
d
e
f
g
h
{{Div col end}}

===Usage of "rules" parameter===
; Example:
<pre>
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|rules=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


===Usage of "gap" parameter===
; Example:
<pre>
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|colwidth=10em|rules=yes|gap=2em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}


===Usage of "small" parameter===
; Example showing how setting "small" parameter to "yes" produces smaller font size
<pre>
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}
</pre>
; produces:
{{Div col|small=yes}}
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

==TemplateData==
{{TemplateDataHeader}}
{{#switch: {{BASEPAGENAME}}
|Div col=<templatedata>
{
"description": "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 closed with {{div col end}}.",
"params": {
"cols": {
"label": "cols",
"description": "Specifies the number of columns.",
"type": "string",
"default": "2",
"aliases": ["1"],
"required": false
},
"colwidth": {
"label": "colwidth",
"description": "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.",
"type": "string",
"aliases": ["2"],
"required": false
},
"rules": {
"label": "rules",
"description": "Produces vertical rules between the columns if set to yes.",
"type": "string",
"required": false
},
"gap": {
"label": "gap",
"description": "Specifies the space between the content of adjacent columns.",
"type": "string",
"required": false
},
"style": {
"label": "style",
"description": "Specifies any custom styling.",
"type": "string",
"required": false
}
}
}
</templatedata>
|Div col end=<templatedata>
{
"description": "Ends a multi-column list started by {{div col}}. It takes no parameters.",
"params": {
}
}
</templatedata>
}}

==Redirects==
{{#ifeq:{{ROOTPAGENAME}}|Div col|
* {{Tlx|Div col start}}
* {{Tlx|Colbegin}} (but '''not''' {{Tlx|Col begin}})
* {{Tlx|Cols}}
}}
{{#ifeq:{{ROOTPAGENAME}}|Div col end|
*{{Tlx|Col div end}}
*{{Tlx|Colend}} (but '''not''' {{Tlx|Col end}})
*{{Tlx|Div end}}
*{{Tlx|Divcol-end}}
*{{Tlx|Divcolend}}
*{{Tlx|Divend}}
*{{Tlx|End div col}}
*{{Tlx|EndDivCol}}
}}

==See also==
{{Column-generating template families}}

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
[[Category:Multi-column templates]]

<!--?:-->{{#switch:{{PAGENAME}} |Div col= |Div col end=}}
[[es:Plantilla:Div col]]
}}</includeonly>
Anonymous user