模板:Diagonal split header/doc

這是 Template:Diagonal split header模板文檔
當直接瀏覽時,使用變量可能會失效,請不要寫死頁面名或地址。

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

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
2023 2024 
Dec Jan Feb
Roma Rome 8 1 6
Venezia Venice 3 5 7
Firenze Florence 4 9 2

Template data[編輯原始碼]

# Label Description Example Type Required
1 Rows Header of row headers, shown on the bottom left Y-axis string true
2 Columns Header of column headers, shown on the top right X-axis string true
3 Background colour Optional colour of background, use transparent for standard non-header background. Default = #eaecf0 transparent string false

See also[編輯原始碼]