模板:Hidden/doc

来自决策链云智库
< 模板:Hidden
Zeroclanzhang讨论 | 贡献2024年1月21日 (日) 18:25的版本 (创建页面,内容为“{{Documentation subpage}} <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> {{high-use}} {{Template:Collapse Templates}} This template creates a dynamic navigation box using style sheet declarations in MediaWiki:Common.css and Javascript code in MediaWiki:Common.js. In a saved, rendered page this template creates a clickable link that toggles between [show…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

This template creates a dynamic navigation box using style sheet declarations in MediaWiki:Common.css and Javascript code in MediaWiki:Common.js. In a saved, rendered page this template creates a clickable link that toggles between [show] and [hide]. It displays the first parameter (the heading) with a [show] link on the right. If [show] is clicked by the user, it displays the second parameter (the body) below the heading and the [show] link becomes [hide]. Clicking on [hide] then hides the body and the [hide] link becomes [show] again.

If this template is nested in another, the show/hide links in the hidden content keep their state; there is no parameter for collapse all or reveal all.

Generally, collapsible templates should not be used in articles. For allowable uses and other considerations, please see MOS:COLLAPSE.

Usage

Full syntax

{{Hidden
| expanded=true <!--(omit for initial hidden state)-->
| style = 
| headerstyle = 
| header = 
| contentstyle = 
| content =

|titlebgcolor= |contentbgcolor= |ta1= |ta2= |fw1= |fw2= |class= |border=
}}

Parameters

Only two parameters are required for this template:

header
text for header (title); alternative to using unnamed parameter {{{1}}}
content
text for body (content); alternative to using unnamed parameter {{{2}}}

Optional

style
CSS styling for template overall.
border
border around the template.
headerstyle
CSS styling for title (header).
contentstyle
CSS styling for the hidden content.
expanded
any nonblank value (e.g. |expanded=on) will cause the template to be initially expanded by default.
multiline
any nonblank value (e.g. |multline=y) will reduce the line-height of the title and add some padding to avoid overlap with the show/hide button.
class
add additional class attributes affecting the entire template.

Note: This template will not respect the user preference "justify paragraphs".

Examples

Basic

In this example only the two required parameters are specified.

模板:Rh | Code
{{hidden|Title text here|Body text line 1<br/>Body text line 2}}
模板:Rh | Result {{模板:PAGENAMETDOC|Title text here|Body text line 1
Body text line 2}}

Header background

模板:Rh | Code
{{hidden
|Title text here
|Body text line 1<br/>Body text line 2
|headerstyle=background:#ccccff
|style=text-align:center;
}}
模板:Rh | Result {{模板:PAGENAMETDOC|Title text here|Body text line 1
Body text line 2|headerstyle=background:#ccccff|style=text-align:center;}}

CSS

模板:Rh | Code
{{hidden
| style = border: 1px dashed red; width: 50%;
| headerstyle = background: #ccccff; font-size: 110%;
| contentstyle = text-align: center; color: green;
| header = Title text here
| content = Body text line 1<br />Body text line 2<br />Body text line 3
}}
模板:Rh | Result

{{模板:PAGENAMETDOC

style = border:1px dashed red; width: 50%; headerstyle = background: #ccccff; font-size: 110%; contentstyle = text-align: center; color:green; header = Title text here content = Body text line 1
Body text line 2
Body text line 3

}}

Issues

Show/hide button overlap

With ta1=right or a long header, the header may overlap the show/hide button:

{{[[Template:模板:PAGENAMETDOC|模板:PAGENAMETDOC]]|<Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.>|<def>}}

模板:Clr

Possible workaround is to use |multiline=y:

"{{hidden|multiline=y|Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.|def}}" gives "{{ 模板:PAGENAMETDOC|multiline=y|Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.|def}}"

Example with long header

{{ 模板:PAGENAMETDOC|abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc |def}}

模板:Clr

Above example with workaround:

"{{hidden|multiline=y|abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc |def}}" gives "{{ 模板:PAGENAMETDOC|multiline=y|abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc |def}}"

Sections

Sections included inside a hidden block result in broken anchors in the table of contents at the top of the page.

example

You can't get here from the table of contents

Templatedata

模板:Templatedata header

Creates a dynamic navigation box which is initially collapsed by default.

模板参数

参数描述类型状态
Header1headertitle

Text for the header/title.

未知可选
Content2contentscontenttext

Text for the content of the hidden.

未知可选
Toggletoggleshowhide

无描述

未知可选
Expandedexpandedexpand

无描述

未知可选
Classclass

Add additional class attributes affecting the entire template.

未知可选
CSScssstyleframestyle

无描述

未知可选
Borderborder

Border around the template

未知可选
Title background colortitlebgcolorbg1background

无描述

未知可选
Title aligntitlealignta1

无描述

未知可选
Multi-linemultilinemulti-line

无描述

未知可选
Title font weightfw1

无描述

未知可选
Header styleheadercssheaderstyletitlestyle

无描述

未知可选
Content background colorcontentbgcolorbg2

无描述

未知可选
ta2ta2

无描述

未知可选
fw2fw2

无描述

未知可选
contentcsscontentcsscontentstyle

Content style

未知可选

Tracking category

See also

Supporting templates:

Similar templates: