Difference between revisions of "Template:Diagonal split header"

From blackwiki
Jump to navigation Jump to search
imported>Cmglee
(Darken line)
imported>Cmglee
(Document)
Line 1: Line 1:
style="background:linear-gradient(to top right,#f2f2f2 49%,#666,#f2f2f2 51%)"|<div style="margin-left:2em;text-align:right;">{{{2|}}}</div>{{{3|}}}<div style="margin-right:2em;text-align:left;">{{{1|}}}</div>
+
<includeonly>style="background:linear-gradient(to top right,#f2f2f2 49%,#999,#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:
 +
{| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:center;"
 +
! {{diagonal split header|&nbsp;&nbsp;Sex|&nbsp;&nbsp;Handed-<br />ness}} !! Right-handed !! Left-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 horizontally with <code>&amp;nbsp;</code> and vertically with <code>&lt;br /&gt;</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 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" style="margin-left:auto;margin-right:auto;text-align:center;"
 +
! colspan="2" rowspan="2" {{diagonal split header|''&theta;''|''H''}} !! 5&prime;&thinsp;7&Prime; !! 5&prime;&thinsp;10&Prime; !! 6&prime;&thinsp;1&Prime;
 +
|-
 +
! 67&Prime; !! 70&Prime; !! 73&Prime;
 +
|-
 +
! 0 !! 0&deg;
 +
| &#10003; || &#10007;|| &#10008;
 +
|-
 +
! {{pi}}/2 !! 90&deg;
 +
| &#10004; || &#10007; || &#10008;
 +
|-
 +
! {{pi}} !! 180&deg;
 +
| &#10004; || &#10004; || &#10003;
 +
|}
 +
</noinclude>

Revision as of 19:51, 9 January 2016

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:

  Handed-
ness
  Sex
Right-handed Left-handed Total
Male 43 9 52
Female 44 4 48
Total 87 13 100

To use it, create a header cell using ! followed by {{diagonal split header|HEADER-OF-ROW-HEADERS|HEADER-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 horizontally with &nbsp; and vertically with <br /> 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 cells using colspan or rowspan, in which case place the colspan/rowspan attribute between ! and {{diagonal split header …}}:

H
θ
5′ 7″ 5′ 10″ 6′ 1″
67″ 70″ 73″
0
Template:Pi/2 90°
Template:Pi 180°