跳转到内容

模板:Collapse/doc

来自天灾之下:危险连接资料站
wiki>RogueScholar2025年5月2日 (五) 11:01的版本 (Create initial template documentation subpage)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

模板参数

此模板有自定义格式。

参数描述类型状态
Titletitle 2

The heading which describes the box's contents and is the only thing shown when in the collapsed state

默认值
{{PAGENAME}}
示例值
Some additional technical details…
单行文本必需
Contentcontent 1

The page content to appear within the collapsible box

示例值
Lorem ipsum dolor sit amet,…
内容必需
Default expansion stateexpand

When assigned the value 'no', the container's default appearance becomes its collapsed state

默认值
yes
示例值
no
布尔可选
Title background colorheader-c

Background color of the box title's rectangular element, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)

默认值
#eaecf0
示例值
goldrenrod
单行文本可选
Background colorbackground-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.).

默认值
white
示例值
#abcdef
单行文本可选
Title text colorheader-fc

Font text color of the box's title, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)

默认值
black
示例值
indigo
单行文本可选
Text colorcolor

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

默认值
#222
示例值
dimgray
单行文本可选
Title font weightheader-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

推荐值
normal bold lighter bolder 100 200 300 400 500 600 700 800 900
默认值
bold
示例值
500
单行文本可选
Title text sizeheader-fs

Size of the box's title text font, must be a valid CSS length value with unit suffix or a relative size keyword

推荐值
xx-small x-small small medium large x-large xx-large xxx-large
默认值
0.95rem
单行文本可选
Text sizefont-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

推荐值
xx-small x-small small medium large x-large xx-large xxx-large
默认值
0.85rem
单行文本可选
Title alignmentheader-align

Sets the horizontal alignment of the box's title within its rectangular element

推荐值
start end left right center justify match-parent justify-all
默认值
center
示例值
left
单行文本可选
Content alignmentalign

Sets the horizontal alignment of the box's contents

推荐值
start end left right center justify match-parent justify-all
默认值
none
示例值
justify
单行文本可选
Title paddingheader-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)

默认值
0.15rem
示例值
0.4rem
单行文本可选
Content paddingpadding

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)

默认值
0.4em 0.8em 0.2em
示例值
1rem
单行文本可选
Widthwidth

The width of the collapsible box, either as an exact CSS length value with unit suffix or relative percentage of the page or viewport

默认值
100%
示例值
50vw
单行文本可选
Margin widthmargin

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

推荐值
auto 0.25rem 0.5rem 0.75rem 1rem 1.25rem 1.5rem 1.75rem 2rem
默认值
0.75rem auto 1.25rem
示例值
1rem
单行文本可选
Float clearanceclear

Forces box to move below any floating elements on either or both page margins that prevent it from extending there

推荐值
none left right both inline-start inline-end
默认值
both
示例值
both
单行文本可选
Title border widthheader-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'

推荐值
thin medium thick
默认值
thin
示例值
medium
单行文本可选
Border widthborder-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'

推荐值
thin medium thick
默认值
thin
示例值
2px
单行文本可选
Title border styleheader-bs

Style of the box title rectangular element's border

推荐值
none hidden dotted dashed solid double groove ridge inset outset
默认值
solid
示例值
ridge
单行文本可选
Border styleborder-s

Style of the box's outer border

推荐值
none hidden dotted dashed solid double groove ridge inset outset
默认值
solid
示例值
double
单行文本可选
Title border colorheader-bc

Color of the box title rectangular elements's outer border, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)

默认值
#a4aab080
示例值
navy
单行文本可选
Border colorborder-c

Color of the box's outer border, must be a valid CSS color value (named, hexadecimal code, RGB decimals, etc.)

默认值
#aaa
示例值
darkslateblue
单行文本可选
Extra CSS classesclass

Adds additional class names to the top-level 'div' HTML container element

示例值
toccolours
单行文本可选
Extra CSS style declarationsstyle

Defines additional CSS style declarations to be added to the collapsible container's outer table element, multiple declarations must be semicolon-delimited

示例值
white-space: nowrap;
字符串可选

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: