Template:Navbox/doc
Using this template to create a navigation template can be relatively convenient and fast to summarize related articles (here refers to category:Navbox templates).
This has many variable parameters, which can be used with {{Navbox subgroup}}, {{Navbox with columns}}, {{Navbox with collapsible groups}}.
Contents
Common parameters
- name
- The name of the template (the part after "Template:", not the title of the template), like: "Moe points".
- title
- The text in the title bar, like: "Moe • moe points", not necessarily the same as
name
. - state
[mw-uncollapsed, mw-collapsed]
- The folded state of the box.
- titlestyle, groupstyle, evenstyle
- CSS styles for the title bar, group, and even list (this part is light green by default), like:
background:gray
- above
- The content displayed above the group/list section.
- groupn
- The text on the left, before listn (if groupn is omitted, listn starts from the left side of the box).
- listn
- List the text of wiki links, usually separated by dots, like: [[A]] • [[B]] • …
- below
- The optional text displayed under the group/list section.
The source code containing common parameters can be copied and used to quickly create a navbox template |
---|
Please delete the unused parameters and do not keep them. {{Navbox |name = {{subst:PAGENAME}} |title = |state = |titlestyle= background: |groupstyle= background: |evenstyle = background: |above = |group1= |list1 = [[]] • <!-- -->[[]] |group2= |list2 = [[]] • <!-- -->[[]] |group3= |list3 = [[]] • <!-- -->[[]] |group4= |list4 = [[]] • <!-- -->[[]] |group5= |list5 = [[]] • <!-- -->[[]] |group6= |list6 = [[]] • <!-- -->[[]] |below = }} |
Most of the other parameters of Navbox are not commonly used, so the commonly used parameters are encapsulated into two simplified templates: {{Daikazoku}} ({{Daikazoku template}}) and {{Daikazoku content line}} ({{Links}}).
For the effects of some commonly used parameters, please refer to #Table layout, #Examples; further details and complex constraints are explained in the #Parameter description section below.
Parameter description
Below is a complete list of parameters used in {{Navbox}}. In most cases, as long as the parameters name
, title
and list1
are sufficient, although subgroup You don’t even need to set those parameters.
{{Navbox}} shares many common parameters with its sister templates {{Navbox with columns}} and {{Navbox with collapsible groups}} to improve consistency and ease of use. A parameter marked with "†" applies to all three master templates.
Setting parameters
- name†
- The name of the template. In order for the "View • Talk • Edit" link to work correctly on all pages that use the generated template, this parameter needs to be set. You can enter
{{subst:PAGENAME}}
as the value of this parameter, which is also a quick way. This parameter is required.
- state†
[mw-uncollapsed, mw-collapsed, plain, off]
- If set to
mw-collapsed
, the navigation frame will always be displayed in a collapsed state at the beginning. - If set to
plain
, the navigation box will always be expanded without the "hidden" link on the right side, and the title will remain centered (by using padding to offset "View • Talk • Edit" link). - If set to
off
, the navigation box will always be expanded without the "hidden" link on the right, but no padding will be used to keep the title centered. This is just for advanced usage; the "plain" option should satisfy most applications that need to hide the "show"/"hide" buttons. - If set to a value other than
mw-collapsed
,plain
oroff
(like "mw-uncollapsed"), the navigation The box will always appear in an expanded state at the beginning, but with a "hide" button.
- If set to
- Many times, for a navbox, the editor will want a default initial state, and it can be overwritten in the entry. To do this, here is a trick:
- In your template, create a parameter also named "state" as a pass, like this:
|state = {{{state<includeonly>|Initial state you want</includeonly>}}}
<includeonly>|
will cause the template to be expanded when viewing the template page itself.
- navbar†
- The default is
Navbar
. If it is set toplain
, the View • Talk • Edit link on the left side of the title bar will not be displayed, and the padding will be automatically applied to keep the title centered. Set tooff
to remove the View •Talk • Edit link, but no padding will be applied (this is just for advanced usage; the "plain" option should satisfy most unwanted The application of the navigation bar.) It is strongly recommended that users do not hide the navigation bar, in order to make it easier for users to edit the template, and to have a standard style throughout each page.
- border†
[subgroup, child, none]
- If set to the above three values, the navigation frame will have no border, but there are still some differences in usage. See Subgroup navbox for details.
- class
- Set class for the main table element of Navbox
cell
- title†
- Display the text at the center of the top row of the table. It is usually the subject of the template, which is a brief description of the main content. This should be a single line, but if you need a second line, please use
{{brClear}}
to ensure correct centering. This parameter is not technically necessary, but it is quite meaningless to use {{Navbox}} without a title.
- groupn†
- (Ie "group1", "group2", etc.) If specified, the text will be displayed in the header cell on the left side of "listn". If omitted, ``listn occupies the entire width of the table.
- listn†
- (Ie "list1", "list2", etc.) The main body of the template, usually a column of links. The format is inline; however, if the entire list is loaded into
<div> </div>
, the text can be entered on different lines. At least one "list" parameter is required; each additional "list" is displayed in a separate table row. Each listn may have a corresponding groupn parameter in front of it, if provided (see below).
- image†
- A picture will be displayed in a cell to the right of the main body (group/list) under the title (title). In order for the picture to be displayed correctly, the list1 parameter must be specified. The image parameter accepts standard wiki codes to display pictures, namely:
image = [[File:Example.jpg|100px]]
(see Help:image)
- imageleft†
- A picture will be displayed in a cell on the left side of the main body (list) under the title (title). In order for the picture to be displayed correctly, the "list1" parameter must be specified, and the group cannot be specified. The imageleft parameter accepts standard wiki code to display pictures, namely:
imageleft = [[File:Example.jpg|100px]]
- above†
- A full-width cell, displayed between the title bar and the first group/list, that is, above the main body (group, list, and image) of the template. In a template without an image, ``above works in the same way as the list1 parameter without the group1 parameter.
- below†
- A full-width cell, displayed below the main body (group, list, and image) of the template. In a template without a picture, below and the last of the template without the groupn parameter listn The parameters operate in the same way. As an example of using the below parameter, see {{Africa}}.
Style parameters
- style†
- Specify the CSS styles applied to the main body of the template. The bodystyle parameter also has the same effect as the following example, and can be used to replace the style parameter. This option should be used with caution, as it can cause visual inconsistencies. For example:
style = background:#nnnnnn;
style = width:N [em/%/px or width:auto];
style = float:[left/right/none];
style = clear:[right/left/both/none];
- titlestyle†
- CSS style applied to title, the most common one is the background color of the navigation bar:
titlestyle = background:#nnnnnn;
titlestyle = background:name;
- groupstyle†
- CSS style applied to all "group" cells. This option overrides any styles applied to the entire table. For example:
groupstyle = background:#nnnnnn;
groupstyle = text-align:[left/center/right];
groupstyle = vertical-align:[top/middle/bottom];
- groupnstyle†
- CSS style applied to a specific "groupN". With the highest display priority, you can specify different groups to display different effects.
- liststyle†
- CSS style applied to all list. If the following listnstyle, "oddstyle" or "evenstyle" parameters are specified, their priority is higher than this parameter.
- listnstyle†
- CSS style applied to a specific listN. With the highest display priority, you can specify different lists to display different effects.
- oddstyle, evenstyle
- Applies to odd/even numbered lists. Will override the style defined by
liststyle
. The default performance is to add striped colors (white and gray) to odd/even rows respectively to improve readability. Except in very special circumstances, these settings should not be changed.
- evenodd
[swap, even, odd]
- Set to
swap
to flip the parity of each list; it can be used to solve the problem of misalignment of the parity pattern after inserting the sub-navigation box. - Set to
even
orodd
to make all the list styles be the style of even-numbered or odd-numbered rows.
- abovestyle†, belowstyle†
- Apply to the top cell (specified by the above parameter) and the bottom cell (specified by the below parameter). It is typically used to set the background color or text alignment:
abovestyle = background:#nnnnnn;
abovestyle = text-align:``left/center/right;
Default style
The style settings listed here are those that are changed most often by editors who use the navigation box. Other more complex style settings are excluded from 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-numbered lists have the color bodystyle, and the default value is #fdfdfd (white with a little gray). A list has a text-align:left;
setting, if it has a group; otherwise, it has a text-align:center;
setting. Since only "bodystyle" has a vertical-align attribute, all other styles inherit its vertical-align:middle;
setting.
Table layout
The table generated by {{Navbox}} without the image, above and below parameters (the gray list background color is added just for demonstration):
|
The table generated by {{Navbox}} with the image, above and below parameters (the gray list background color is added just for demonstration):
|
The table generated by {{Navbox}} with image, imageleft, lists, and without groups, above and below (the gray list background color is added just for demonstration):
|
Examples
Without pictures
-{}-{{Navbox |name = Navbox/doc |title = [[Oarai Women’s Academy]] Student Club Members |group1= Volleyball Club |list1 = [[Isobe Noriko]] • <!-- -->[[Shinobu Kawanishi]] • <!-- -->[[Sasaki Asuka]] • <!-- -->[[Kondo Taeko]] |group2= Automotive Club |list2 = [[Nakajima Riro]] • <!-- -->[[Suzuki (Girls und Panzer)|Suzuki]] • <!-- -->[[Hoshino (Girls und Panzer)|Hoshino]] • <!-- -->[[Tsuchiya (Girls und Panzer)|Tsuchiya]] |group3= Broadcasting Club |list3 = [[Taiga Oo]] }}
|
With pictures, without grouping
-{}-{{Navbox |name = Navbox/doc |title = [[Oarai Women’s Academy]] Student Club Members |image = [[File:GUP_Ooarai.svg|80px]] |group1= Volleyball Club |list1 = [[Isobe Noriko]] • <!-- -->[[Shinobu Kawanishi]] • <!-- -->[[Sasaki Asuka]] • <!-- -->[[Kondo Taeko]] |group2= Automotive Club |list2 = [[Nakajima Riro]] • <!-- -->[[Suzuki (Girls und Panzer)|Suzuki]] • <!-- -->[[Hoshino (Girls und Panzer)|Hoshino]] • <!-- -->[[Tsuchiya (Girls und Panzer)|Tsuchiya]] |group3= Broadcasting Club |list3 = [[Taiga Oo]] }}
|
With two pictures, without grouping, multiple lists
-{}-{{Navbox |name = Navbox/doc |title = [[Oarai Women’s Academy]] Student Club Members |image = [[File:GUP_Ooarai.svg|80px]] |imageleft = [[File:GUP Logo Alpha0.svg|80px]] |list1 = [[Isobe Noriko]] • <!-- -->[[Shinobu Kawanishi]] • <!-- -->[[Sasaki Asuka]] • <!-- -->[[Kondo Taeko]] |list2 = [[Nakajima Riro]] • <!-- -->[[Suzuki (Girls und Panzer)|Suzuki]] • <!-- -->[[Hoshino (Girls und Panzer)|Hoshino]] • <!-- -->[[Tsuchiya (Girls und Panzer)|Tsuchiya]] |list3 = [[Taiga Oo]] }}
|
With pictures, groupings, above note, below note
-{}-{{Navbox |name = Navbox/doc |title = [[Oarai Women’s Academy]] Student Club Members |image = [[File:GUP_Ooarai.svg|80px]] |above = (Only list members who have joined the clubs) |group1= Volleyball Club |list1 = [[Isobe Noriko]] • <!-- -->[[Shinobu Kawanishi]] • <!-- -->[[Sasaki Asuka]] • <!-- -->[[Kondo Taeko]] |group2= Automotive Club |list2 = [[Nakajima Riro]] • <!-- -->[[Suzuki (Girls und Panzer)|Suzuki]] • <!-- -->[[Hoshino (Girls und Panzer)|Hoshino]] • <!-- -->[[Tsuchiya (Girls und Panzer)|Tsuchiya]] |group3= Broadcasting Club |list3 = [[Taiga Oo]] |below = "[[Girls und Panzer]]" official website: https://girls-und-panzer.jp/ }}
|
- Main page: Template:Navbox subgroup
To place the subgroup navbox in the parent navbox, using {{Navbox subgroup}} is recommended. But the same effect can be achieved by adding |border = subgroup/child
in {{Navbox}} or setting the first parameter (unnamed) to subgroup/child
. The subgroup navbox does not require the name
parameter.
{{Navbox subgroup |group1= |list1 = |group2= |list2 = ... }}
{{Navbox|border=subgroup |group1= |list1 = |group2= |list2 = ... }}
{{Navbox|subgroup |group1= |list1 = |group2= |list2 = ... }}
It looks like this:
{{{group1}}} | {{{list1}}} |
{{{group2}}} | {{{list2}}} |
…… |
Then put it into a list (you can increase the indentation to indicate the hierarchical relationship). E.g:
-{}-{{Navbox |name = Navbox/doc |title = Example of sub-navbox |group1= Group 1 |list1 = List 1 |group2= group 2 |list2 = {{Navbox subgroup |evenodd = swap |group1= Group 2.1 |list1 = List 1 |group2= Group 2.2 |list2 = List 2 |group3= Group 2.3 |list3 = List 3 }} |group3= Group 3 |list3 = List 3 }}
|
It can be noticed that a evenodd
parameter is used above, which is used to adjust the distribution of striped color bands in some sub-groups to ensure that the color bands are arranged crosswise. If you want to remove all striped color bands, you can set liststyle = background:transparent
in each Navbox.
From the designer's perspective, border = subgroup
and border = child
are suitable for different situations. When set to subgroup, the group is narrower, and it is suitable for the group of the sub-navbox to be arranged side by side with the group of the parent navbox. For example, in the above example, group 2.X and group 2 are in a row; while the group of child keeps the default width, which is suitable for the child The group of the navigation box serves as the first-level group, such as #Multiple expand/collapse below. Template:Nonsense
The appearance of border = none
is similar to that of subgroup and child, but it is suitable for "not used in navigation box", such as putting {{Navbox|none…}}
is embedded in some other template (not this template and its sister templates). On the contrary, do not embed subgroups and children into templates other than Navbox and sister templates, which will cause potential errors.
Multiple expand/collapse
- Main page: Template:Navbox with collapsible groups
When there is too much content in the navbox template, you can consider using multiple expand/collapse. You can use {{Navbox with collapsible groups}}, which is more convenient and intuitive. It can also be achieved using only Navbox:
{{Navbox |name = Navbox/doc |title = …… |list1 = {{Navbox|child |navbar = plain |title = …… ... }} |list2 = {{Navbox|child |navbar = plain |title = …… ... }} |list3 = {{Navbox|child |navbar = plain |title = …… ... }} }}
|
This navbox template is specially designed to work with two other sister templates: {{Navbox with columns}} and {{Navbox with collapsible groups}}. All three templates share common parameters to improve consistency and ease of use (such parameters are marked with † in the complete parameter list above). Most importantly, all three templates can be used as child templates of one another (by using the border = child
parameter, or specifying the first parameter (unnamed) as child
. For example, use {{Navbox|child…}}
, {{Navbox with columns|child…}}
or {{Navbox with collapsible groups|child…}}
).
Technical details
- This template uses CSS classes for most of its appearance, so it can completely replace the skin.
- For more technical details, please refer to the CSS classes in the discussion page, MediaWiki:Common.css and MediaWiki:Common.js to hide the box The collapsible table.
Operation details
- The list cell width is initially set to 100%. Therefore, if you want to manually set the width of the grouped cells, you need to specify the liststyle to have width:auto at the same time. If you want to set the grouping width and use images, it depends on you have figured out the CSS in the groupstyle, liststyle, imagestyle, and imageleftstyle parameters to make all components work properly. The following two lines are examples of setting the grouping width:
groupstyle = width:10em;
liststyle = width:auto;
- Adjacent navigation boxes have only a 1px border between them. If you set the top margin (margin-top) or bottom margin (margin-bottom) of
style / bodystyle
, then this feature will not work. - The default left margin (margin-left) and right margin (margin-right) of the outer navigation box table are set to "auto;". If you want to use the navigation box as a float, you need to manually set the left and right margins, because auto margins will prevent the float option. For example, add the following code to use the navigation box as a floating object:
style = width:22em;float:right;margin-left:1em;margin-right:0
See also
- {{Navbox subgroup}}-Allow grouping in the navbox.
- {{Navbox with columns}}-Allow columns to replace groups/lists.
- {{Navbox with collapsible groups}}-another variant.
- {{Nobold}}-When the default text style is set to bold, it can be used to display a template without bold text.
- {{W}} (•) – Dots that separate list items.
- {{nav-s}}-Display predecessor and successor navigation templates in the title.
|