来自魔法纪录中文Wiki
跳转至: 导航 搜索

The {{collapse top}} template (or {{cot}}), and its paired template {{collapse bottom}} (or {{cob}}), are used for placing a collapse box around a talk page discussion, especially when the content contains complex wikimarkup such as tables. For very simple content, the one-piece template {{collapse}} can be used instead.

These templates should only be used in accordance with the Wikipedia:Refactoring guideline; they should never be used to end a discussion over the objections of other editors, except in cases of unambiguous disruptive editing.

Usage

Place {{collapse top}} (or {{cot}}), and {{collapse bottom}} (or {{cob}}), around the text to be collapsed. For example:

{{collapse top|title=This is the title text}}
Sample contents text
{{collapse bottom}}

produces:

This is the title text

Sample contents text

Parameters

This template takes the following parameters, all of which are optional

positional parameter 1, named parameter 'title'
These parameters give the main title of collapsed box, which occurs on the same line as the show link and is always visible. It defaults to 'Extended content'. For example, {{collapse top|This is the title text}} or {{collapse top|title=This is the title text}}
warning
If this parameter evaluates to true (i.e. is not empty) it will display a default warning line under the main title which reads "The following is a closed debate. Template:Strongbad" For example, {{collapse top|This is the title text|warning=true}}
positional parameter 2
This is optional warning-line text. It will override the standard warning line above, and make the 'warning' parameter unnecessary. For example, {{collapse top|This is the title text|This is a custom warning line}}
left
If this parameter evaluates to true (i.e. is not empty) it will align the 'parameter 1 title' along the left margin. Text aligns centered between the left margin and the left bracket of the left show link by default. For example, {{collapse top|This is the title text|left=true}}
expand
If this parameter evaluates to true (i.e. is not empty) it will leave the material uncollapsed with the border and coloring. Default is to collapse the material. For example, {{collapse top|This is the title text|expand=true}}
bg
Sets the background color of the collapsed material. Defaults to #CFC - a pleasant green. Other colors available from List of colors. For example, {{collapse top|This is the title text|bg=#F0F2F5}}
fc
Sets the font color of the title of the collapsible bar. Defaults to Black. Other colors available from List of colors. For example, {{collapse top|This is the title text|fc=#F0F2F5}}
border
Sets the width of the border line on the collapsed material. defaults to 1px. For example, {{collapse top|This is the title text|border=2px}}
b-color
Sets the border color. defaults to silver. For example, {{collapse top|This is the title text|b-color=#F0F2F5}}
padding
Sets the padding on the collapsed material in the colored area. Defaults to 8px. For example, {{collapse top|This is the title text|padding=16px}}
width
Sets the width of the overall template. Use |width=50%, not |Width=50% as upper case "W" doesn't work. Or |width=200px (if you omit "px" it doesn't work).
border2
Sets the border of the box that appears when template is expanded; defaults to "1px silver" (there is no provision to change from a solid line). For example, {{collapse top|This is the title text|border2=2px}}
bg2
Sets background of the box that appears when template is expanded; defaults to white. For example, {{collapse top|This is the title text|bg2=#F0F2F5}}
indent
indents the box from the left of the page. Use: |indent=50px not |Indent=50px (upper case "I" doesn't work). Defaults to "do not indent" (i.e. 0px). Each ":" in wiki-markup is approximately equivalent to 25px indent.
clear
In some situations you may not want the default clear: both; CSS to apply, with puts the collapse box below any left- or right-floated content within the same HTML block. In this case, you can use |clear=none, |clear=right, or |clear=left, as needed.

Examples

  • Adding a box title (if omitted, default is 'Extended content') - {{collapse top|This is the title text}}
This is the title text

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Adding a standard warning line - {{collapse top|This is the title text|warning=true}}
This is the title text
The following is a closed debate. Template:Strongbad

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Adding a custom warning line - {{collapse top|This is the title text|This is a custom warning line}}
This is the title text
This is a custom warning line

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Aligning box title along left margin - {{collapse top|left=true}}
Extended content

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Changing background color - {{collapse top|bg=#F0F2F5}}
Extended content

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Adding extra padding - {{collapse top|padding=40px}}
Extended content

本文为测试文字。这段文字用于说明格式,请勿删除。

  • Archiving a section: the markup below:
{{collapse top}}
==Section header==
Sample contents text
{{collapse bottom}}

must be rewritten as:

{{collapse top|Section header}}
Sample contents text
{{collapse bottom}}

The end result:

Section header

Sample contents text

重定向

重定向至Collapse top:

重定向至Collapse bottom: