「User:Chronowar/sandbox3」:修訂間差異
無編輯摘要 |
無編輯摘要 |
||
第66行: | 第66行: | ||
}} | }} | ||
==参数 | ==参数 描述== | ||
[[模板:Navbox|Navbox]]使用小写的参数名称。 | |||
[[模板:Navbox|Navbox]]使用小写的参数名称 | |||
如果省略其他参数,必需的<code>name</code>和<code>title</code>会创建一个单行方框。 | 如果省略其他参数,必需的<code>name</code>和<code>title</code>会创建一个单行方框。 | ||
:其它的所有变量都是可选的。 | :其它的所有变量都是可选的。 | ||
下面是用于Navbox的 参数 的一个完整清单。在大多数情况 下 ,只要有参数<code>name</code>、<code>title</code>和几个<code>group</code>和<code>list</code>就可以了。 | |||
{| class="wikitable" style="text-align:center" | {| class="wikitable" style="text-align:center" | ||
|- | |- | ||
第95行: | 第79行: | ||
|- | |- | ||
|<code>name</code> | |<code>name</code> | ||
|该索引模板的名称(“模板:”后面的部分,注意不是模板的标题)。 | |该索引模板的名称(“模板:”后面的部分,注意不是模板的标题)。 你可以输入<code><nowiki>{{subst:PAGENAME}}</nowiki></code>作为这个参数的值,这也是个快捷的方法。<!-- 事实上仅当<code>title</code>被指定,且<code>border</code>参数未被设置时,此name参数才是必需的,但是目前不支持border函数。 --> | ||
|- | |- | ||
|<code>title</code> | |<code>title</code> | ||
|标题栏中的文字,例如<code><nowiki>[[Arcaea]]</nowiki></code>。 | |标题栏中的文字, 作为主体内容的一个简要描述。 例如<code><nowiki>[[Arcaea]]</nowiki></code> 。 | ||
<ref>这应该是单独的一行,但是如果需要第二行,请使用<code><nowiki>{{brClear}}</nowiki></code>来保证正确的居中。</ref>本参数从技术上来说不是必需的,但是使用Navbox而不带标题是相当没有意义的 。 | |||
|- | |- | ||
|<code>state</code> | |<code>state</code> | ||
| | | 几 个状态 :<code>autocollapse 、uncollapsed、collapsed 、plain、off</code><br /> | ||
缺省为<code>autocollapse</code>。如果在使用了其他可折叠表格 的 同一个页面上有两个或更多表格,那么navbox一开始就会 折叠 起来。<!--要了解技术上的实现,请参见[[MediaWiki:Common.js]]。--><br /> | |||
<code>collapsed</code>:该导航框总会在开始时以折迭起来的 状态 展现。<br /> | |||
<code>plain</code>:该导航框会不带右侧的“隐藏”链接 , 并且标题会保持居中。<br /> | |||
<code>off</code>:该导航框总会在被展开时不带右侧的“隐藏”链接,但是没有补白以保持标题居中。<ref>这只是为了高级用 法 ;“plain”选项应能满足大多数需要将“显示”/“隐藏”按钮隐藏起来的情况。</ref><br /> | |||
除上述4个值之外的其他值(例如“uncollapsed”),该导航框总会在开始时以展开的状态出现,但是带有“隐藏”按钮 。 | |||
<ref>若要在单独显示框体,而在一个条目中时自动隐藏内容,可以将“uncollapsed”置于<nowiki><noinclude></nowiki>标签之内: | |||
<code>state = </code><nowiki><noinclude>uncollapsed</noinclude></nowiki></ref> | |||
|- | |- | ||
|<code>titlestyle</code> | |<code>titlestyle</code> | ||
第127行: | 第119行: | ||
|在group/list区段之下显示的可选文字,与<code>above</code>性质相同。 | |在group/list区段之下显示的可选文字,与<code>above</code>性质相同。 | ||
|} | |} | ||
其他的一些替代导航格式:[[#表格布局|表格布局]]。 | |||
===高级 参数/复杂 描述=== | |||
<!-- | |||
== | |||
:; ''navbar''<sup>†</sup> | :; ''navbar''<sup>†</sup> | ||
::缺省为<code>Navbar</code>。如果设置为<code>plain</code>,在标题栏左侧的<small>查 • 论 • 编</small>链接不会显示出来,而且补白会被自动应用以保持标题居中。设置为<code>off</code>可以移除<small>查 • 论 • 编</small>链接,但是不会应用补白(这只是为了高级用法;“plain”选项应能满足大多数不想要导航栏的应用。)强烈建议使用者不要隐藏导航栏,为的是使用户编辑该模板更加容易,并且可以贯穿各个页面都有一个标淮的风格。 | ::缺省为<code>Navbar</code>。如果设置为<code>plain</code>,在标题栏左侧的<small>查 • 论 • 编</small>链接不会显示出来,而且补白会被自动应用以保持标题居中。设置为<code>off</code>可以移除<small>查 • 论 • 编</small>链接,但是不会应用补白(这只是为了高级用法;“plain”选项应能满足大多数不想要导航栏的应用。)强烈建议使用者不要隐藏导航栏,为的是使用户编辑该模板更加容易,并且可以贯穿各个页面都有一个标淮的风格。 | ||
中文模板目前不支持此参数。2008-10-23 | 中文模板目前不支持此参数。2008-10-23 | ||
:; ''border''<sup>†</sup> | :; ''border''<sup>†</sup> | ||
::''关于将导航框用在另一个导航框内部,欲了解示例及更完整的描述,请参见下面的章节。''如果设置为<code>child</code>或<code>subgroup</code>,那么该导航框能够被用作一个无边框的子导航框。其边框被隐藏并且在表格的边上没有补白,因此它能很好地放进它的父导航框的list区域。如果设置为<code>none</code>,那么 | ::''关于将导航框用在另一个导航框内部,欲了解示例及更完整的描述,请参见下面的章节。''如果设置为<code>child</code>或<code>subgroup</code>,那么该导航框能够被用作一个无边框的子导航框。其边框被隐藏并且在表格的边上没有补白,因此它能很好地放进它的父导航框的list区域。如果设置为<code>none</code>,那么 | ||
:: ''See section below on using navboxes within one another for examples and a more complete description.'' If set to <code>child</code> or <code>subgroup</code>, 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. If set to <code>none</code>, 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 <code>none</code> option inside of another navbox; similarly, only use the <code>child</code>/<code>subgroup</code> 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 (i.e. use the first unnamed parameter instead of the named ''border'' parameter): | :: ''See section below on using navboxes within one another for examples and a more complete description.'' If set to <code>child</code> or <code>subgroup</code>, 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. If set to <code>none</code>, 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 <code>none</code> option inside of another navbox; similarly, only use the <code>child</code>/<code>subgroup</code> 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 (i.e. use the first unnamed parameter instead of the named ''border'' parameter): | ||
:::<code><nowiki>{{Navbox|child</nowiki></code> | :::<code><nowiki>{{Navbox|child</nowiki></code> | ||
第159行: | 第133行: | ||
:::<code><nowiki>}}</nowiki></code> | :::<code><nowiki>}}</nowiki></code> | ||
--> | --> | ||
:; ''title''<sup>†</sup> | :; ''title''<sup>†</sup> | ||
::显示在表格顶端一行居中位置的文字 | ::显示在表格顶端一行居中位置的文字。 | ||
:; ''group<sub>n</sub>''<sup>†</sup> | :; ''group<sub>n</sub>''<sup>†</sup> | ||
::(即''group1''、''group2''等等)如果被指定,文字会显示在位于''list<sub>n</sub>''左侧的抬头单元格中。如果被省略,''list<sub>n</sub>''占用表格的全部宽度。 | ::(即''group1''、''group2''等等)如果被指定,文字会显示在位于''list<sub>n</sub>''左侧的抬头单元格中。如果被省略,''list<sub>n</sub>''占用表格的全部宽度。 | ||
第331行: | 第303行: | ||
*外层导航框表格的缺省的左外边距(margin-left)和右外边距(margin-right)被设置为“auto;”。如果你想使用导航框作为一个浮动对象(float),你需要手动设置左外边距和右外边距的值,因为自动外边距(auto margins)会阻止浮动(float)选项。例如,添加下列代码来使用导航框作为一个浮动对象: | *外层导航框表格的缺省的左外边距(margin-left)和右外边距(margin-right)被设置为“auto;”。如果你想使用导航框作为一个浮动对象(float),你需要手动设置左外边距和右外边距的值,因为自动外边距(auto margins)会阻止浮动(float)选项。例如,添加下列代码来使用导航框作为一个浮动对象: | ||
::<code>style = width:22em;float:right;margin-left:1em;margin-right:0em;</code> | ::<code>style = width:22em;float:right;margin-left:1em;margin-right:0em;</code> | ||
==备注== | |||
<references /> |
於 2020年10月12日 (一) 16:45 的修訂
本頁面作為本地化模板:Navbox/doc的頁面,僅供參考。
以下是正文內容。
正文
該模板來自維基百科,功能可能有所缺失。 由於本地化未完成,可能缺失了非必要性的模板,導致一部分功能無法使用。 |
本模板允許通過提供一個或多個連結列表相對快速地建立一個索引模板。
使用
請移除置空不用的參數。
{{Navbox | state = autocollapse <!--autocollapse、uncollapsed、collapsed、plain、off--> | name = {{subst:PAGENAME}} | title = | image = | above = | abovestyle = | listclass = hlist | group1 = | list1 = | group2 = | list2 = | group3 = | list3 = | group4 = | list4 = | group5 = | list5 = | group6 = | list6 = | group7 = | list7 = | group8 = | list8 = | group9 = | list9 = | group10 = | list10 = | group11 = | list11 = | group12 = | list12 = | group13 = | list13 = | group14 = | list14 = | group15 = | list15 = | group16 = | list16 = | group17 = | list17 = | group18 = | list18 = | group19 = | list19 = | group20 = | list20 = | belowstyle = | below = }} |
參數描述
Navbox使用小寫的參數名稱。
如果省略其他參數,必需的name
和title
會創建一個單行方框。
- 其它的所有變量都是可選的。
下面是用於Navbox的參數的一個完整清單。在大多數情況下,只要有參數name
、title
和幾個group
和list
就可以了。
變量名 | 說明 |
---|---|
name
|
該索引模板的名稱(「模板:」後面的部分,注意不是模板的標題)。你可以輸入{{subst:PAGENAME}} 作為這個參數的值,這也是個快捷的方法。
|
title
|
標題欄中的文字,作為主體內容的一個簡要描述。例如[[Arcaea]] 。
[1]本參數從技術上來說不是必需的,但是使用Navbox而不帶標題是相當沒有意義的。 |
state
|
幾個狀態:autocollapse、uncollapsed、collapsed、plain、off 缺省為 |
titlestyle
|
應用於標題欄的一個CSS樣式字符串,例如background:gray
|
groupstyle
|
應用於分組單元格的一個CSS樣式字符串,例如background:#eee;
|
image
|
一個可選的右側圖片,以完整的文件形式編碼,例如[[文件:Packs arcaea.jpg|75px]]。 |
imageleft
|
一個可選的左側圖片,格式與「image」參數相同。 |
above
|
在group/list區段之上顯示的文字。 |
groupn
|
左側的文字,在list-n之前作為描述文本(如果group-n被省略,list-n從方框的左側開始)。 |
listn
|
列出條目名稱,通常以圓點符號模板(模板:·)分隔開來,例如[[Antagonism]]{{·}} [[Dantalion]]
|
below
|
在group/list區段之下顯示的可選文字,與above 性質相同。
|
其他的一些替代導航格式:表格佈局。
高級參數/複雜描述
- title†
- 顯示在表格頂端一行居中位置的文字。
- groupn†
- (即group1、group2等等)如果被指定,文字會顯示在位於listn左側的抬頭單元格中。如果被省略,listn佔用表格的全部寬度。
- listn†
- (即list1、list2等等)該模板的主體,通常為一欄連結。格式為內聯;然而,如果整個列表被裝入
<div> </div>
之內,文字能夠被輸入到不同的行中。最少需要一個list參數;每個附加的list被顯示在一個單獨的表格行中。每個listn可能在其前面有一個相對應的groupn參數,如果提供了的話(參見下方)。 - image†
- 一張圖片,會顯示在標題(title)之下、主體(group/list)之右側的一個單元格中。為使圖片能正確地顯示,必須指定list1參數。image參數接受標淮的維基代碼來顯示圖片,即:
image = [[File:Example.jpg|100px]]
- imageleft†
- 一張圖片,會顯示在標題(title)之下、主體(list)之左側的一個單元格中。為使圖片能正確顯示,必須指定list1參數,而且不能指定分組(group)。imageleft參數接受標淮的維基代碼來顯示圖片,即:
imageleft = [[File:Example.jpg|100px]]
- above†
- 一個全寬度單元格,顯示在標題欄與第一個group/list之間,也就是位於該模板的主體(group、list和image)之上。在一個不帶圖片的模板中,above與不帶group1參數的list1參數以同樣的方式運作。
- below†
- 一個全寬度單元格,顯示在該模板主體(group、list和image)的下方。在一個不帶圖片的模板中,below與該模板最後面的不帶groupn參數的listn參數以同樣的方式運作。作為一個使用了below參數的示例,請參見{{非洲}}。
樣式參數
一般不建議更改樣式,以保持模板和網頁的一致性。然而,修改樣式的選項還是有的。
- style†
- 指定應用到模板主體的CSS樣式。bodystyle參數也有下面舉例的同樣效果,並能被用來代替這個style參數。此選項應謹慎使用,因為它可以導致視覺上的不一致。舉例:
style = background:#nnnnnn;
style = width:N [em/%/px or width:auto];
style = float:[left/right/none];
style = clear:[right/left/both/none];
- titlestyle†
- 應用到title的CSS樣式,最常見的有導航欄的背景顏色:
titlestyle = background:#nnnnnn;
titlestyle = background:name;
- groupstyle†
- 應用到groupN單元格的CSS樣式。該選項覆寫應用於整個表格的任何樣式。舉例:
groupstyle = background:#nnnnnn;
groupstyle = text-align:[left/center/right];
groupstyle = vertical-align:[top/middle/bottom];
- liststyle†
- 應用到所有list的CSS樣式。若指定了下面的oddstyle和evenstyle參數,則它們的優先級高於本參數。
- oddstyle
- evenstyle
- 應用到奇數/偶數編號的列表。會推翻由liststyle定義的樣式。缺省的表現是分別添加條紋狀的顏色(白色和灰色)到奇數/偶數行,以提高可讀性。除了在非常特別的情況下,這些設置不應更改。
- abovestyle†
- belowstyle†
- CSS樣式,應用到頂端單元格(通過above參數指定)和底端單元格(通過below參數指定)。典型地被用來設置背景顏色或文本對齊方式:
abovestyle = background:#nnnnnn;
abovestyle = text-align:[left/center/right];
缺省樣式
這裏列出的樣式設置是使用導航框的編輯者最經常更改的那些設置。其他更加複雜的樣式設置被排除在這個列表之外,以保持它簡單。大多數樣式是在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;
由於liststyle和oddstyle是透明的,奇數列表有bodystyle的顏色,其缺省值是#fdfdfd(白色帶有少許灰色)。一個list有text-align:left;
設定,如果它有一個group的話;否則,它有text-align:center;
設定。由於只有bodystyle有一個垂直對齊(vertical-align)屬性,所 有其他樣式繼承其vertical-align:middle;
設定。
表格佈局
由{{Navbox}}不帶image、above和below參數生成的表格(添加了灰色的列表背景色僅僅是為了演示):
|
由{{Navbox}}帶有image、above和below參數生成的表格(添加了灰色的列表背景色僅僅是為了演示):
|
由{{Navbox}}帶有image、imageleft、lists,且不帶groups、above、below生成的表格(添加了灰色的列表背景色僅僅是為了演示):
|
技術細節
- 此模板為其大部分外觀使用CSS類,因此它完全可以更換皮膚。
- 欲了解更多技術細節請參見其討論頁、MediaWiki:common.css中的CSS類以及MediaWiki:common.js中用來隱藏框體的可折迭表格。
運作詳情
- 列表單元格寬度初始被設置為100%。因此,如果你想手動設置分組單元格的寬度,你就需要同時指定liststyle使之有width:auto。如果你想設置分組寬度並使用圖片,這取決於你已弄明白在groupstyle、liststyle、imagestyle和imageleftstyle參數中的CSS,以使所有部件都工作正常。以下兩行是設置分組寬度的示例:
groupstyle = width:10em;
liststyle = width:auto;
- 相鄰的導航框在它們之間僅有一個1px的邊框(除了在IE6中,因其不支持必需的CSS)。如果你設置了
style/bodystyle
的頂端外邊距(top margin)或底頂端外邊距(bottom margin),那麼此特性就不運作了。 - 外層導航框表格的缺省的左外邊距(margin-left)和右外邊距(margin-right)被設置為「auto;」。如果你想使用導航框作為一個浮動對象(float),你需要手動設置左外邊距和右外邊距的值,因為自動外邊距(auto margins)會阻止浮動(float)選項。例如,添加下列代碼來使用導航框作為一個浮動對象:
style = width:22em;float:right;margin-left:1em;margin-right:0em;