Manual:Collapsible elements/zh

jQuery.makeCollapsible


请参阅文档来了解关于该功能生效方式的更多信息. ''
 * 参见以获取更多示例. 

从MediaWiki 1.18以及更高版本起，此模块默认包含在MediaWiki 核心中. 此模块默认随MediaWiki一起提供. 你并不需要将其复制进wiki中. The source (if you're interested) is in the repository for mediawiki-core ( and ).

给任意元素（div、table、list等任何元素）加入 类以启用.

在移动版上不生效（T111565）.

表格
表格可以像任何其他元素一样折叠. 区别是，表格的部分内容会保持显示，即使已经被折叠. 带有表格标题（caption）的标题会保持表格标题可见：

A table without a caption keeps the first row visible:

结果：



指定初始状态
You can add  after   to have the content collapsed by default when you load the page.

To set the initial state as collapsed add " ", such as seen in the following table:

You can add a padded border around the caption to make it easier to see that it is a collapsed table:


 * + style="white-space:nowrap; border:1px solid; padding:3px;" | The caption remains visible.

简单
结果：

This text is collapsible.

Using the  and   attributes one can define a custom text for the toggle labels added by the script. When added in wikitext these could be populated by a localized message like:



简单带有标题
结果：

Lorem ipsum sample This text is collapsible.



带有指定的可折叠部分
By default, a collapsible non-table element collapses completely.

To keep some content visible, even when collapsed, you can specify which part is the collapsible content.

结果：

This text is not collapsible; but the next is collapsible and hidden by default:



带有自定义的开关链接
If you don't want the script to put the default toggle link (whether or not with a custom label) in your element, you can make one of your own. This could reside anywhere inside or outside the collapsible element. Its relationship to the collapsible element is detected by using an ID attribute with the prefix  and a corresponding class attribute with prefix   for the collapsible element and the togglelink respectively.

结果：

Toggle link Toggled text Additional toggle link

Inside another element
You can also use collapsible elements in other elements, such as a table.



将开关移到左边
Wide images and long bare URLs in collapsible tables or elements can cause the toggle link to go offscreen to the right when expanded. In cell phones for example. Sometimes it is difficult or impossible to get over to the toggle link to click it and close it. The following CSS puts the toggle link all the way to the left, and leaves a little space between it and the text to its right. The toggle link position does not change as the table or element is expanded or collapsed. Place the CSS in common.css by editing page "MediaWiki:common.css". Also edit mobile.css if you are importing jquery.makeCollapsible into mobile.js. For examples see common.css, mobile.js, and mobile.css

Removing brackets from the toggle
If you want to hide the brackets in the default or custom label toggle links (for aesthetic or other reasons):



参见

 * en:Help:Table