模板:Pp-template
模板:Esoteric
本模板與{{Navbox}}大致相近,惟獨不同的是本模板是完全對應英語維基百科的Template:Navbox(2008年5月2日修訂版本),引入了子導航模板(Child navboxes)及其他進階的參數選項。
{{Navbox2
|name = {{subst:PAGENAME}}
|title =
|titlestyle =
|state =
|navbar =
|image =
|imagestyle =
|imageleft =
|imageleftstyle =
|style =
|basestyle =
|above =
|abovestyle =
|groupstyle =
|liststyle =
|listpadding =
|oddstyle =
|evenstyle =
|evenodd =
|group1 =
|list1 =
|group2 =
|list2 =
...
|group20 =
|list20 =
|below =
|belowstyle =
|titlegroup =
|titlegroupstyle =
|innerstyle =
}}
以下是{{Navbox2}}的完整參數列表。在大多數的情況下,必須填寫的參數是name
、title
及list1
,儘管使用子導航模板時甚至可以忽略這些參數。
標記為*的參數是{{Navbox}}和{{Navbox2}}的共同參數,如果您只會用到*標記的參數,建議您直接使用{{Navbox}}。
- name *
- 模板的名稱。(→詳細的解說請見{{Navbox}}。)
- state * [
autocollapse, uncollapsed, collapsed, plain, off
]
- 模板的初始摺疊狀態。(→詳細的解說請見{{Navbox}}。)
- navbar *
- 模板標題欄左方的導航列。(→詳細的解說請見{{Navbox}}。)
- border / 未命名參數{{{1}}}
- 模板的邊框設定,主要應用於子導航模板的顯示形式。如果設定為
child
或subgroup
,then the navbox can be used as a borderless child that fits snuggly in another navbox. The border is hidden and there is no padding on the sides of the table, so it fits into the list area of its parent navbox。如果設定為none
,then the border is hidden and padding is removed, and the navbox may be used as a child of another container (do not use the none
option inside of another navbox; similarly, only use the child
/subgroup
option inside of another navbox). If set to anything else (default), then a regular navbox is displayed with a 1px border. An alternate way to specify the border to be a subgroup style is like this (即是使用首個未命名參數而非border命名參數):
{{Navbox2|child
...
}}
- title *
- 模板的標題欄文字。(→詳細的解說請見{{Navbox}}。)
- groupn *
- 模板的組別欄。(→詳細的解說請見{{Navbox}}。)
- listn *
- 模板的列表欄(內容部分)。(→詳細的解說請見{{Navbox}}。)
- image *
- 模板右方的圖像。(→詳細的解說請見{{Navbox}}。)
- imageleft *
- 模板左方的圖像。(→詳細的解說請見{{Navbox}}。)
- above *
- 模板標題欄下的頂欄。(→詳細的解說請見{{Navbox}}。)
- below *
- 模板的底欄。(→詳細的解說請見{{Navbox}}。)
- style *
- 模板總體的CSS樣式設定。(→詳細的解說請見{{Navbox}}。)
- basestyle
- CSS styles to apply to the title, above, below, and group cells all at once. The style are not applied to list cells. This is convenient for easily changing the basic color of the navbox without having to repeat the style specifications for the different parts of the navbox. Examples:
basestyle = background:lightskyblue;
- titlestyle *
- 模板標題欄的CSS樣式設定。(→詳細的解說請見{{Navbox}}。)
- groupstyle *
- 模板組別欄的CSS樣式設定。(→詳細的解說請見{{Navbox}}。)
- groupnstyle
- CSS styles to apply to a specific group, in addition to any styles specified by the groupstyle parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity. Examples:
group3style = background:red;color:white;
- liststyle *
- CSS styles to apply to all lists. Overruled by the oddstyle and evenstyle parameters (if specified) below.
- listnstyle
- CSS styles to apply to a specific group, in addition to any styles specified by the groupstyle parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity. Examples:
list5style = background:#ddddff;
- listpadding
- A number and unit specifying the padding in each list cell. The list cells come equipped with a default padding of 0.25em on the left and right, and 0em on the top and bottom. Due to complex technical reasons, simply setting "liststyle=padding:0.5em;" (or any other padding setting) will not work. Examples:
listpadding = 0.5em 0em;
(sets 0.5em padding for the left/right, and 0em padding for the top/bottom.)
listpadding = 0em;
(removes all list padding.)
- oddstyle * 及 evenstyle *
- Applies to odd/even list numbers. Overrules styles defined by liststyle. The default behavior is to add striped colors (white and gray) to odd/even rows, respectively, in order to improve readability. These should not be changed except in extraordinary circumstances.
- evenodd
[swap, even, odd, off]
- If set to
swap
, then the automatic striping of even and odd rows is reversed. Normally, even rows get a light gray background for striping; when this parameter is used, the odd rows receive the gray striping instead of the even rows. Setting to even
or odd
sets all rows to have that striping color. Setting to off
disables automatic row striping. This advanced parameter should only be used to fix problems when the navbox is being used as a child of another navbox and the stripes do not match up. Examples and a further description can be found in the section on child navboxes below.
- abovestyle * 及 belowstyle *
- CSS styles to apply to the top cell (specified via the above parameter) and bottom cell (specified via the below parameter). Typically used to set background color or text alignment:
abovestyle = background:#nnnnnn;
abovestyle = text-align:[left/center/right];
- imagestyle 及 imageleftstyle
- CSS styles to apply to the cells where the image/imageleft sits. These styles should only be used in exceptional circumstances, usually to fix width problems if the width of groups is set and the width of the image cell grows too large. Examples:
imagestyle = width:5em;
The style settings listed here are those that editors using the navbox change most often. The other more complex style settings were left out of this list to keep it simple. Most styles are set in MediaWiki:Common.css.
bodystyle = background:#fdfdfd; width:100%; vertical-align:middle;
titlestyle = background:#ccccff; padding-left:1em; padding-right:1em; text-align:center;
abovestyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center;
belowstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center;
groupstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:right;
liststyle = background:transparent; text-align:left/center;
oddstyle = background:transparent;
evenstyle = background:#f7f7f7;
Since liststyle and oddstyle are transparent odd lists have the color of the bodystyle, which defaults to #fdfdfd (white with a hint of gray). A list has text-align:left;
if it has a group, if not it has text-align:center;
. Since only bodystyle has a vertical-align all the others inherit its vertical-align:middle;
.
- titlegroup
- This puts a group in the title area, with the same default styles as groupn. It should be used only in exceptional circumstances (usually advanced meta-templates) and its use requires some knowledge of the internal code of {{Navbox}}; you should be ready to manually set up CSS styles to get everything to work properly if you wish to use it. If you think you have an application for this parameter, it might be best to change your mind, or consult the talk page first.
- titlegroupstyle
- The styles for the titlegroup cell.
- innerstyle
- A very advanced parameter to be used only for advanced meta-templates employing the navbox. Internally, the navbox uses an outer table to draw the border, and then an inner table for everything else (title/above/groups/lists/below/images, etc.). The style/bodystyle parameter sets the style for the outer table, which the inner table inherits, but in advanced cases (meta-templates) it may be necessary to directly set the style for the inner table. This parameter provides access to that inner table so styles can be applied. Use at your own risk.
本模板支援多個導航模板的嵌入。要嵌入子導航模板,可以設定border參數或首個未命名參數為「child」。實現此功能的基本代碼如下(這將會於首個組別/列表欄內增加一個子組別):
{{Navbox2
|name = {{subst:PAGENAME}}
|title = 標題
|group1 = [選填]
|list1 = {{Navbox2|child
...子導航模板參數...
}}
...
}}
模板:See Also
以下的範例顯示了子組別的用法。建議使用現有的{{Navbox subgroup}}模板以實現子組別的功能,但是相同的效果亦可透過{{Navbox2}}直接實現,只要設定border = child
或設定首個未命名參數為child
即可。注意您可能需要使用evenodd參數來顛倒條紋背景的排序,以便正確輸出條紋隔行顯示的次序。如果您想移除全部的條紋背景樣式,您可以在每個的子導航模板內設定liststyle = background:transparent;
。
多子組別範例 |
---|
| 頂欄 | | 組別1 | 列表1 | | 組別2 | 組別2.1 | 列表2.1 | | 組別2.2 | 列表2.2 | | 組別2.3 | 列表2.3 |
| | 組別3 | 組別3.1 | 列表3.1 | | 組別3.2 | 組別3.2.1 | 列表3.2.1 | | 組別3.2.2 | 列表3.2.2 |
| | 組別3.3 | 組別3.3.1 | 組別3.3.1.1 | 列表3.3.1.1 | | 組別3.3.1.2 | 列表3.3.1.2 |
| | 組別3.3.2 | 列表3.3.2 |
|
| | 組別4 | 組別4.1 | | 列表4.1 | | 組別4.2 | | 組別4.2.1 | 列表4.2.1 | | 組別4.2.2 | 列表4.2.2 |
|
| | 底欄 |
|
{{Navbox2
|name = Navbox2/doc
|state = uncollapsed
|title = 多子組別範例
|above = 頂欄
|below = 底欄
|group1 = 組別1
|list1 = 列表1
|group2 = 組別2
|list2 =
{{Navbox2|child
|evenodd = swap
|group1 = 組別2.1
|list1 = 列表2.1
|group2 = 組別2.2
|list2 = 列表2.2
|group3 = 組別2.3
|list3 = 列表2.3
}}
|group3 = 組別3
|list3 =
{{Navbox2|child
|group1 = 組別3.1
|list1 = 列表3.1
|group2 = 組別3.2
|list2 = {{Navbox2|child
|evenodd = swap
|group1 = 組別3.2.1
|list1 = 列表3.2.1
|group2 = 組別3.2.2
|list2 = 列表3.2.2
}}
|group3 = 組別3.3
|list3 = {{Navbox2|child
|group1 = 組別3.3.1
|list1 = {{Navbox2|child
|evenodd = swap
|group1 = 組別3.3.1.1
|list1 = 列表3.3.1.1
|group2 = 組別3.3.1.2
|list2 = 列表3.3.1.2
}}
|group2 = 組別3.3.2
|list2 = 列表3.3.2
}}
}}
|group4 = 組別4
|list4 =
{{Navbox2|child
|list1style = background:#ddf;
|list1 = '''組別4.1'''
|list2style = background:transparent;
|list2 = 列表4.1
|list3style = background:#ddf;
|list3 = '''組別4.2'''
|list4 = {{Navbox2|child
|group1 = 組別4.2.1
|list1 = 列表4.2.1
|group2 = 組別4.2.2
|list2 = 列表4.2.2
}}
}}
}}
模板:See Also
以下的範例是由正規的導航模板作為主模板,其list1、list2及list3參數分別包含不同的導航模板,並設定了border = child
。注意每個子導航模板都有其獨立的導航列;要隱藏導航列,可以為每個子導航模板設定navbar = plain
,或直接漏空name參數(子導航模板不會要求用戶設定name參數,有別於正規的導航模板)。
多子摺疊項目範例 |
---|
| 子摺疊項目1 |
---|
| 頂欄 | | | 組別1 | 列表1 | | | 組別2 | 列表2 | | 組別3 | 列表3 | | 組別4 | 列表4 | | 組別5 | 列表5 |
| | | | 子摺疊項目3 |
---|
| 組別1 | 組別1.1 | 列表1.1 | | 組別1.2 | 列表1.2 | | 組別1.3 | 列表1.3 |
| | 組別2 | 組別2.1 | 列表2.1 | | 組別2.2 | 列表2.2 | | 組別2.3 | 列表2.3 |
| | 組別3 | 列表3 | | 底欄 |
|
|
{{Navbox2
|name = Navbox2/doc
|title = 多子摺疊項目範例
|state = uncollapsed
|list1 = {{Navbox2|child
|name = Navbox2/doc
|title = 子摺疊項目1
|above = 頂欄
|image = [[File:Example.png|100px]]
|imageleft = [[File:Example.jpg|100px]]
|groupstyle = background:lavender;
|group1 = 組別1
|list1 = 列表1
|group2 = 組別2
|list2 = 列表2
|group3 = 組別3
|list3 = 列表3
|group4 = 組別4
|list4 = 列表4
|group5 = 組別5
|list5 = 列表5
}}
|list2 = {{Navbox2|child
|name = Navbox2/doc
|title = 子摺疊項目2
|list1 = 列表1
|list2 = 列表2
}}
|list3 = {{Navbox2|child
|name = Navbox2/doc
|title = 子摺疊項目3
|below = 底欄
|groupstyle = background:lavender;
|group1 = 組別1
|list1 = {{Navbox2|child
|group1 = 組別1.1
|list1 = 列表1.1
|group2 = 組別1.2
|list2 = 列表1.2
|group3 = 組別1.3
|list3 = 列表1.3
}}
|group2 = 組別2
|list2 = {{Navbox2|child
|evenodd = swap
|group1 = 組別2.1
|list1 = 列表2.1
|group2 = 組別2.2
|list2 = 列表2.2
|group3 = 組別2.3
|list3 = 列表2.3
}}
|group3 = 組別3
|list3 = 列表3
}}
}}