模板:Collapse/doc
| 文件:Codex icon book color-base.svg | This is a documentation subpage for 模板:Collapse. It contains usage information, categories and other content that is not part of the original 模板 page. |
This template, {{Collapse}}, creates a collapsible container for page content that would benefit from an (optional) ability to be hidden from view, with the ability to appear in either the collapsed or expanded state by default.
Usage
In its simplest functional use case, the template's invocation need only include the parameters for the container's title and contents, taking the form:
{{Collapse|title=Box title|content=The contents of the box…}}
Blank example blocks
With common parameters only
Below is an example of the template formatted as a block with the most commonly used parameters, plus guidance on valid values where applicable; please delete all unused parameters before saving if copied and pasted.
{{Collapse
| title =
| expand = <!-- 'no' to default to collapsed state, otherwise leave unset -->
| background-c =
| align =
| padding =
| content = <!-- Box content goes here -->
}}
With all parameters
Below is an example of the template formatted as a block with all possible named parameters, plus guidance on valid values where applicable; please delete all unused parameters before saving if copied and pasted.
{{Collapse
| title =
| expand = <!-- 'no' to default to collapsed state, otherwise leave unset -->
| background-c =
| color =
| font-size =
| align =
| padding =
| width =
| margin =
| clear = <!-- [ none | left | right ] -->
| border-w = <!-- [ thin | medium | thick ] or absolute length -->
| border-s = <!-- [ none | hidden | dotted | dashed | double | groove | ridge | inset | outset ] -->
| border-c =
| header-align = <!-- [ start | end | left | right | justify | match-parent | justify-all ] -->
| header-c =
| header-bw = <!-- [ thin | medium | thick ] or absolute length -->
| header-bs = <!-- [ none | hidden | dotted | dashed | double | groove | ridge | inset | outset ] -->
| header-bc =
| header-fc =
| header-fs =
| header-fw = <!-- [ 100 | 200 | 300 | normal | 500 | 600 | bold | 800 | 900 ] -->
| header-p =
| class =
| style =
| content = <!-- Box content goes here -->
}}
TemplateData
This is the TemplateData documentation for this template used by VisualEditor and other tools.
Collapse
Places page content that consumes excess vertical space or is likely to interest only a subset of readers within a collapsible box that can appear in either state by default, keeping it in place and accessible without detriment to the overall layout or readability
| 参数 | 描述 | 类型 | 状态 | |
|---|---|---|---|---|
| Title | title 2 | The heading which describes the box's contents and is the only thing shown when in the collapsed state
| 单行文本 | 必需 |
| Content | content 1 | The page content to appear within the collapsible box
| 内容 | 必需 |
| Default expansion state | expand | When assigned the value 'no', the container's default appearance becomes its collapsed state
| 布尔 | 可选 |
| Title background color | header-c | Background color of the box title's rectangular element, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)
| 单行文本 | 可选 |
| Background color | background-c | The background color for the box's contents, which also narrowly surrounds the title in the collapsed state; must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.).
| 单行文本 | 可选 |
| Title text color | header-fc | Font text color of the box's title, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)
| 单行文本 | 可选 |
| Text color | color | Font text color of the box's content and, optionally, its title; must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.).
| 单行文本 | 可选 |
| Title font weight | header-fw | Sets the thickness of the title text font, must be an unsigned (positive) integer between 100 and 900, inclusive, or a relative CSS font-weight keyword
| 单行文本 | 可选 |
| Title text size | header-fs | Size of the box's title text font, must be a valid CSS length value with unit suffix or a relative size keyword
| 单行文本 | 可选 |
| Text size | font-size | Font size of the text content contained within the box, must be a valid CSS length value with unit suffix or a relative size keyword
| 单行文本 | 可选 |
| Title alignment | header-align | Sets the horizontal alignment of the box's title within its rectangular element
| 单行文本 | 可选 |
| Content alignment | align | Sets the horizontal alignment of the box's contents
| 单行文本 | 可选 |
| Title padding | header-p | Sets the padding of the box title's rectangular element, or the distance from which it extends in all four directions beyond the title text; must be composed of 1–4 valid CSS length value(s) with unit suffix(es)
| 单行文本 | 可选 |
| Content padding | padding | Defines the thickness of the null space between the box's contents and its borders, must be composed of 1–4 valid CSS length value(s) with unit suffix(es)
| 单行文本 | 可选 |
| Width | width | The width of the collapsible box, either as an exact CSS length value with unit suffix or relative percentage of the page or viewport
| 单行文本 | 可选 |
| Margin width | margin | Defines the size of the collapsible box's margins from other elements on the page, must consist of 1–4 valid CSS length values with unit suffix
| 单行文本 | 可选 |
| Float clearance | clear | Forces box to move below any floating elements on either or both page margins that prevent it from extending there
| 单行文本 | 可选 |
| Title border width | header-bw | Thickness of the box title rectangular element's border, must be a valid CSS length value with unit suffix or one of: 'thin', 'medium' or 'thick'
| 单行文本 | 可选 |
| Border width | border-w | Thickness of the box's outer border, must be a valid CSS length value with unit suffix or one of: 'thin', 'medium' or 'thick'
| 单行文本 | 可选 |
| Title border style | header-bs | Style of the box title rectangular element's border
| 单行文本 | 可选 |
| Border style | border-s | Style of the box's outer border
| 单行文本 | 可选 |
| Title border color | header-bc | Color of the box title rectangular elements's outer border, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)
| 单行文本 | 可选 |
| Border color | border-c | Color of the box's outer border, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)
| 单行文本 | 可选 |
| Extra CSS classes | class | Adds additional class names to the top-level 'div' HTML container element
| 单行文本 | 可选 |
| Extra CSS style declarations | style | Defines additional CSS style declarations to be added to the collapsible container's outer table element, multiple declarations must be semicolon-delimited
| 字符串 | 可选 |
See also
- {{Hidden}} – functionally very similar, but with different aesthetics
- {{Hidden archive top}} (and {{Hidden archive bottom}}) – also similar in function, but meant specifically for pages in Talk namespaces with an included admonition not to disturb the contents in the interests of maintaining a faithful archive of past events
These template pairs also produce a similar content container, but are more compatible with complex wiki markup structures:
- {{Collapse top}} (and {{Collapse bottom}})
- {{Hidden begin}} (and {{Hidden end}})