Difference between revisions of "Template:Div col"

From OpenDominion
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><templatestyles src="Div col/styles.css"/>
+
<includeonly>
 
<div class="div-col {{#ifeq:{{{small|}}}|yes|div-col-small}} {{#ifeq:{{{rules|}}}|yes|div-col-rules}}"  
 
<div class="div-col {{#ifeq:{{{small|}}}|yes|div-col-small}} {{#ifeq:{{{rules|}}}|yes|div-col-rules}}"  
 
{{#if:{{{colwidth|}}}{{{gap|}}}{{{style|}}}|
 
{{#if:{{{colwidth|}}}{{{gap|}}}{{{style|}}}|
 
style="{{#if:{{{colwidth|}}}|column-width: {{{colwidth}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"
 
style="{{#if:{{{colwidth|}}}|column-width: {{{colwidth}}};}}{{#if:{{{gap|}}}|column-gap: {{{gap}}};}}{{#if:{{{style|}}}|{{{style}}}}}"
 
}}>
 
}}>
{{#if:{{{content|}}}|{{{content}}}</div>}} Inventory how many pages use small=yes
+
{{#if:{{{content|}}}|{{{content}}}</div>}}
{{#ifeq:{{{small|}}}|yes|[[Category:Pages using div col with small parameter]]}}
 
 
</includeonly>
 
</includeonly>
 
<noinclude>
 
<noinclude>
Line 13: Line 12:
 
===Descriptions===
 
===Descriptions===
 
There are six parameters for this template:  
 
There are six parameters for this template:  
: Specifies the minimum width of the columns so that the number of columns is automatically based on screen width (that is, more columns will be shown on wider displays). If no value is supplied, the template uses a default of 30em. The width can be specified in any [[CSS#Length units|CSS unit of measure]], for instance, the [[Em (typography)|em]] (about the width of the capital "M" of the displayed typeface), e.g., <code>colwidth=20em</code>.  
+
: Specifies the minimum width of the columns so that the number of columns is automatically based on screen width (that is, more columns will be shown on wider displays). If no value is supplied, the template uses a default of 30em. The width can be specified in any CSS unit of measure, for instance, the em (about the width of the capital "M" of the displayed typeface), e.g., <code>colwidth=20em</code>.  
 
: Adds vertical lines ("rules") between the columns if set to <code>yes</code>.  
 
: Adds vertical lines ("rules") between the columns if set to <code>yes</code>.  
 
: Specifies the space between the content of adjacent columns, in any valid CSS width unit, e.g., <code>gap=2em</code>. The default spacing (set by browser) is 1em.
 
: Specifies the space between the content of adjacent columns, in any valid CSS width unit, e.g., <code>gap=2em</code>. The default spacing (set by browser) is 1em.
Line 222: Line 221:
 
<pre>
 
<pre>
 
{{div col|colwidth=20em}} <!--Lorem ipsum -->
 
{{div col|colwidth=20em}} <!--Lorem ipsum -->
{{lorem ipsum}}
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non congue felis. Ut nisi est, consectetur sit amet risus eu, condimentum efficitur risus. Vestibulum sed consectetur orci. In a elit feugiat, vestibulum lacus sed, finibus nunc. Donec gravida vel magna auctor imperdiet. Ut a bibendum elit, id placerat leo. Cras quis velit dapibus, aliquam ante ac, suscipit nibh. Cras laoreet leo eget elementum lacinia. Vivamus consectetur condimentum velit tincidunt auctor. Sed hendrerit dui vitae tortor volutpat, sit amet tempor libero convallis. Proin a lacinia tellus, eu ullamcorper libero. Maecenas sit amet ligula eu felis tempor faucibus. Quisque ultrices orci euismod metus vulputate, sed viverra urna aliquam.
 
{{div col end}}
 
{{div col end}}
 
</pre>
 
</pre>
 
Produces
 
Produces
 
{{Div col|colwidth=20em}}
 
{{Div col|colwidth=20em}}
{{lorem ipsum}}
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non congue felis. Ut nisi est, consectetur sit amet risus eu, condimentum efficitur risus. Vestibulum sed consectetur orci. In a elit feugiat, vestibulum lacus sed, finibus nunc. Donec gravida vel magna auctor imperdiet. Ut a bibendum elit, id placerat leo. Cras quis velit dapibus, aliquam ante ac, suscipit nibh. Cras laoreet leo eget elementum lacinia. Vivamus consectetur condimentum velit tincidunt auctor. Sed hendrerit dui vitae tortor volutpat, sit amet tempor libero convallis. Proin a lacinia tellus, eu ullamcorper libero. Maecenas sit amet ligula eu felis tempor faucibus. Quisque ultrices orci euismod metus vulputate, sed viverra urna aliquam.
 
{{Div col end}}
 
{{Div col end}}
  
Line 257: Line 256:
 
* h
 
* h
 
}}
 
}}
 
Turning off the {{code|break-inside: avoid-column;}} rule appears to help.<!-- A full page refersh is needed; just F12-ing doesn't work. -->
 
 
</noinclude>
 
</noinclude>

Latest revision as of 19:56, 19 January 2021


The div col (short for division columns) formats a list into columns that wrap at multiple screen resolutions responsively. It automatically breaks the available screen space into equal parts, meaning, for instance, that it is not necessary to guess how many columns to use and then figure out the dividing point(s), e.g., the halfway point to divide the list into two columns, or the one-third and two-thirds points to divide the list into three columns.

This template's parameters[edit]

Descriptions[edit]

There are six parameters for this template:

Specifies the minimum width of the columns so that the number of columns is automatically based on screen width (that is, more columns will be shown on wider displays). If no value is supplied, the template uses a default of 30em. The width can be specified in any CSS unit of measure, for instance, the em (about the width of the capital "M" of the displayed typeface), e.g., colwidth=20em.
Adds vertical lines ("rules") between the columns if set to yes.
Specifies the space between the content of adjacent columns, in any valid CSS width unit, e.g., gap=2em. The default spacing (set by browser) is 1em.
CSS styling to apply to the columns.
Sets font size to 90%.
Content to apply to the columns.

Example of "colwidth" parameter[edit]

{{div col|colwidth=10em}} <!-- column width of 10em -->
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}

Produces:


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


Example of "rules" parameter[edit]

{{Div col|colwidth=10em|rules=yes}} <!-- column width of 10em with rules -->
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

Produces:


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


Example of "gap" parameter[edit]

{{Div col|colwidth=10em|rules=yes|gap=2em}} <!-- column width of 10em with rules and a gap of 2em -->
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

Produces:


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


Example of "small" parameter[edit]

{{Div col|small=yes}} <!-- Small = yes -->
* a
* b
* c
* d
* e
* f
* g
* h
{{Div col end}}

Produces:


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


Example of "content" parameter[edit]

{{Div col|colwidth=10em|content= <!-- content parameter doesn't need {{div col end}} -->
* a
* b
* c
* d
* e
* f
* g
* h
}}

Produces:

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


Usage with multiple parameters[edit]

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

Produces:


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

Colwidth 20em[edit]

{{div col|colwidth=20em}}
* a
* b
* c
* d
* e
* f
* g
* h
{{div col end}}

Produces:


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


Text characters without list markup[edit]

{{div col|colwidth=10em}} <!--Text characters without list markup -->
a
b
c
d
e
f
g
h
{{div col end}}

Produces


a b c d e f g h


Lorem ipsum[edit]

{{div col|colwidth=20em}} <!--Lorem ipsum -->
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non congue felis. Ut nisi est, consectetur sit amet risus eu, condimentum efficitur risus. Vestibulum sed consectetur orci. In a elit feugiat, vestibulum lacus sed, finibus nunc. Donec gravida vel magna auctor imperdiet. Ut a bibendum elit, id placerat leo. Cras quis velit dapibus, aliquam ante ac, suscipit nibh. Cras laoreet leo eget elementum lacinia. Vivamus consectetur condimentum velit tincidunt auctor. Sed hendrerit dui vitae tortor volutpat, sit amet tempor libero convallis. Proin a lacinia tellus, eu ullamcorper libero. Maecenas sit amet ligula eu felis tempor faucibus. Quisque ultrices orci euismod metus vulputate, sed viverra urna aliquam.
{{div col end}}

Produces


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non congue felis. Ut nisi est, consectetur sit amet risus eu, condimentum efficitur risus. Vestibulum sed consectetur orci. In a elit feugiat, vestibulum lacus sed, finibus nunc. Donec gravida vel magna auctor imperdiet. Ut a bibendum elit, id placerat leo. Cras quis velit dapibus, aliquam ante ac, suscipit nibh. Cras laoreet leo eget elementum lacinia. Vivamus consectetur condimentum velit tincidunt auctor. Sed hendrerit dui vitae tortor volutpat, sit amet tempor libero convallis. Proin a lacinia tellus, eu ullamcorper libero. Maecenas sit amet ligula eu felis tempor faucibus. Quisque ultrices orci euismod metus vulputate, sed viverra urna aliquam.


Limitation[edit]

Sub-lists[edit]

The underlying CSS system is unable to break sub-lists into columns. Note the uneven formatting below:

{{Div col|colwidth=10em|rules=yes|gap=2em|style=column-count:3|content=
* a
* b
* c
** c.d
** c.e
** c.f
* g
* h
}}

Produces:

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