Difference between revisions of "Template:Diagonal split header"

From blackwiki
Jump to navigation Jump to search
imported>Cmglee
(Update compatibility documentation)
imported>Crissov
({{docuemntation}})
Line 1: Line 1:
 
<includeonly>style="background:linear-gradient(to top right,#f2f2f2 49%,#aaa,#f2f2f2 51%)"|<div style="margin-left:2em;text-align:right;">{{{2}}}</div>{{{3|}}}<div style="margin-right:2em;text-align:left;">{{{1}}}</div></includeonly><noinclude>
 
<includeonly>style="background:linear-gradient(to top right,#f2f2f2 49%,#aaa,#f2f2f2 51%)"|<div style="margin-left:2em;text-align:right;">{{{2}}}</div>{{{3|}}}<div style="margin-right:2em;text-align:left;">{{{1}}}</div></includeonly><noinclude>
This template simulates a table header cell split diagonally, a device often used to compactly label headers of rows and columns, as in this example:
+
{{documentation}}
{| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:center;"
 
! {{diagonal split header|&nbsp;&nbsp;Sex|&nbsp;&nbsp;Handed-<br />ness}} !! Right-<br />handed !! Left-<br />handed !! Total
 
|-
 
! Male
 
| 43 || 9  || 52
 
|-
 
! Female
 
| 44 || 4  || 48
 
|-
 
! Total
 
| 87 || 13 || 100
 
|}
 
To use it, create a header cell using <code>!</code> followed by <code><nowiki>{{diagonal split header|HEADER-OF-ROW-HEADERS|HEADER-OF-COLUMN-HEADERS}}</nowiki></code>.
 
 
 
As the effect is achieved by drawing a diagonal line across the cell, the two headers are still part of the same cell and can easily overrun the line. A remedy is to pad the headers with <code>&amp;nbsp;</code> as in the example above. The template user is responsible for checking that it does not overrun on common Web browsers.
 
 
 
The template is compatible with collapsible (but not sortable, as the sort arrows are not drawn) tables, and cells using colspan or rowspan, in which case place the colspan/rowspan attribute between <code>!</code> and <code><nowiki>{{diagonal split header &hellip;}}</nowiki></code>:
 
{| class="wikitable sortable collapsible" style="margin-left:auto;margin-right:auto;text-align:center;"
 
! colspan="2" rowspan="2" {{diagonal split header|''&theta;''|''T''}} !! colspan="2"|2015 !! 2016
 
|-
 
! Nov !! Dec !! Jan
 
|-
 
! {{hs|1}} 0 !! 0&deg;
 
| &#10004; || &#10008;|| &#10007;
 
|-
 
! {{hs|2}} {{pi}}/2 !! 90&deg;
 
| &#10003; || &#10007; || &#10008;
 
|-
 
! {{hs|3}} {{pi}} !! 180&deg;
 
| &#10004; || &#10004; || &#10003;
 
|}
 
 
</noinclude>
 
</noinclude>

Revision as of 14:49, 21 January 2016

Template documentation[view] [edit] [history] [purge]

Usage

This template simulates a table header cell split diagonally, a device often used to compactly label headers of rows and columns, as in this example:

To 
From
Solid Liquid Gas
Solid Solid-solid transformation Melting Sublimation
Liquid Freezing Boiling/evaporation
Gas Deposition Condensation

To use it, create a header cell using ! followed by {{diagonal split header|NATURE-OF-ROW-HEADERS|NATURE-OF-COLUMN-HEADERS}}.

As the effect is achieved by drawing a diagonal line across the cell, the two headers are still part of the same cell and can easily overrun the line. A remedy is to pad the headers with non-breaking spaces (&nbsp;), line breaks Template:Nobr and/or CSS (escape = signs as {{=}}), as in the example above. The template user is responsible for checking that it does not overrun on common Web browsers.

Background colour and non-header cells

A third parameter can be added to change the background colour from the standard header cell colour. Changing it to transparent (or another colour such as white, or #ffffff) lets the template be applied to non-header cells. Prefix it with | instead of !, as in this Friend or Foe? payoff matrix:

Pair 2
yellow
Pair 1
"Friend"
(cooperate)
"Foe"
(defect)
"Friend"
(cooperate)
1
#99ff99
1
2
transparent
0
"Foe"
(defect)
0
transparent
2
0
#fcc
0

Spanning columns and rows, and collapsible and sortable tables

The template is compatible with collapsible tables, and cells using colspan or rowspan, in which case place the colspan/rowspan attribute between ! and {{diagonal split header ...}}. It is not compatible with sortable tables, as the sort arrows are not drawn, but this problem can be resolved by using a second header row:

n
  City
2025 2026 
Dec Jan Feb
Roma Rome 8 1 6
Venezia Venice 3 5 7
Firenze Florence 4 9 2

Template data

Simulate a table header cell split diagonally

Template parameters

ParameterDescriptionTypeStatus
Rows1

header of row headers, shown on the bottom left

Example
''Y-axis''
Stringrequired
Columns2

header of column headers, shown on the top right

Example
{{color|#6cf|X-axis}}
Stringrequired
Background colour3

Optional colour of background, use <code>transparent</code> for standard non-header background

Default
#eaecf0
Example
transparent
Stringoptional