پرش به محتوا

الگو:Diagonal split header 2/doc

از ویکی‌پدیا، دانشنامهٔ آزاد


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}}.

There are two variants of the template with different – and sadly incompatible – features:

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 (<br />), 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.

Wiki source Rendered result
{| class="wikitable"
! {{diagonal split header|From|To}}
! Solid !! Liquid !! Gas
|-
! Solid
| Solid-solid transformation || Melting || Sublimation=
|}
To
From
Solid Liquid Gas
Solid Solid-solid transformation Melting Sublimation=

Background colour and non-header cells

[ویرایش]

Diagonal split header only

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.

You may also indicate a second color in the fourth parameter (its default is the same as the third parameter), the first color being used for the lower left half of the cell, the second color being used for the upper right half of the cell.

Prefix it with | for data cells instead of ! for header cells, as in this Friend or Foe? payoff matrix:

Example
Pair 2
cyan
Pair 1
"Friend" (cooperate) "Foe" (defect)
"Friend" (cooperate)
1
transparent
1
2
pink
0
"Foe" (defect)
0
palegreen
2
0
pink
0
Code

Spanning columns and rows, and collapsible and sortable tables

[ویرایش]

Diagonal split header 2 recommended

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 2 ...}}. 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.

In large table cells like this, use Diagonal split header 2 to produce a better-looking line, with the same thickness as the cell borders:

Example
n
City
خطای عبارت: نویسه نقطه‌گذاری شناخته نشده «۲» ۲۰۲۴ 
Dec Jan Feb
Roma Rome 8 1 6
Venezia Venice 3 5 7
Firenze Florence 4 9 2
Code

Template data

[ویرایش]

Simulate a table header cell split diagonally

پارامترهای الگو[ویرایش داده‌های الگو]

پارامترتوضیحاتنوعوضعیت
Rows1

header of row headers, shown on the bottom left

مثال
''Y-axis''
رشتهضروری
Columns2

header of column headers, shown on the top right

مثال
{{color|#6cf|X-axis}}
رشتهضروری
Background colour3

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

پیش‌فرض
#eaecf0
مثال
transparent
رشتهاختیاری
Upper right background colour4

Optional colour of background for the upper right half of the cell, use <code>transparent</code> for standard non-header background

پیش‌فرض
same background colour as parameter 3, #eaecf0 otherwise
مثال
transparent
رشتهاختیاری

Technical notes

[ویرایش]
  • It is possible to create a version without the line-overrun per Krautzberger. This one works by drawing a line and using a 2x2 CSS grid with the bottom-left and top-right corners.

    See caniuse for support of the required css-grid feature; compare with (unprefixed) css-gradients underlying the current implementation.

  • Neither implementation supports laying out text along the diagonal, as the browser is unaware of the triangular shape. CSS-shapes may be a solution, but the easier shape-inside approach is yet to be standardized.