Test2

Материал из Энциклопедия вселенной Diablo
Версия от 20:25, 4 декабря 2013; Fenixs (обсуждение | вклад)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Collapsible table

To make any table collapsible, add a special class collapsible

For example, the following table is defined with {| class="collapsible wikitable":

Always displayed header
Optionally displayed text; optionally displayed text

Initial state

Collapsible table is initially expanded by default.

You can change this with two additional special classes:

  • autocollapse: table will be collapsed if there are more than 2 collapsible tables on the page,
  • collapsed: table will be initially collapsed.

Example: {| class="wikitable collapsible collapsed"

Table width

Since usually the natural width of the header is smaller than of the main content, the table' width will increase after expanding and it will "jump" around. (Also, even if the header would fit in the width of the browser window, the layout engine might divide it over two lines.) It is ugly in itself and inconvenient if you want only to have a quick look at the hidden content and then collapse it again without having to hunt the link with cursor in between. This is prevented by explicitly setting table's width, which then remains the same in the collapsed and expanded state.

Compare this to the first example: {| class="collapsible wikitable" style="width:34em"

Always displayed header, table has width:34em
optionally displayed text: you can see it doesn't matter at all that this is so much longer, table width has been set at 34em

Usage

For content that is not a table one can create a table with only one element with content, and a header. However there's a table-less, purely DIV-based solution available on the Wikipedia - see #Collapsible DIV below.

For existing table one can simply add collapsible class. If the table has several colums, it might be a good idea to add a heading row consisting of one cell otherwise the link will be in the first one. Sometimes an easy solution is to put the whole table as element inside another table (see example below); however this is bad from the webdesign and usability viewpoint.

Sortable collapsible table

Sortable table inside a collapsible table:

initially expanded initially collapsed
class="collapsible" class="collapsible collapsed"
numbers
name number
a 123
b 6
c 45

If the sortable table is itself made collapsible the positioning of the hide/show button is a bit odd:

initially expanded initially collapsed
class="wikitable sortable collapsible" class="wikitable sortable collapsible collapsed"
name number
a 123
b 6
c 45