Template:Navbox: Difference between revisions
m (chrome bug? border-spacing uses rem not em) |
(Extended groups from 10 to 15) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<div role="navigation" aria-labelledby="navbox-{{anchorencode:{{{title}}}}}" class="navbox mw-collapsible {{#ifeq:{{{state|}}}|collapsed|mw-collapsed}}" style="clear: both; position: relative; margin | <div role="navigation" aria-labelledby="navbox-{{anchorencode:{{{title}}}}}" class="navbox mw-collapsible {{#ifeq:{{{state|}}}|collapsed|mw-collapsed}}" style="clear: both; position: relative; margin: 1em auto 0; border: 1px solid #aaa; width: 100%; max-width: 150ch; background-color: #f9f9f9; text-align: center; font-size: 90%; {{{style|}}};"><!-- | ||
---Title--- | ---Title--- | ||
Line 24: | Line 24: | ||
-->{{#if:{{{body|}}}|<!-- | -->{{#if:{{{body|}}}|<!-- | ||
--><div class="mw-collapsible-content nowraplinks" style="margin: 0.2em; {{{bodystyle|}}};"><!-- | --><div class="mw-collapsible-content nowraplinks" style="margin: 0.2em; padding: 0 1em; {{{bodystyle|}}};"><!-- | ||
-->{{{body}}}<!-- | -->{{{body}}}<!-- | ||
--></div><!-- | --></div><!-- | ||
Line 127: | Line 127: | ||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}" style="display: table-cell; padding: {{{list9padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{oddstyle|}}}; {{{list9style|}}};"><!-- | --><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}" style="display: table-cell; padding: {{{list9padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{oddstyle|}}}; {{{list9style|}}};"><!-- | ||
-->{{{list9}}}<!-- | -->{{{list9}}}<!-- | ||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#if:{{{group10|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group10style|}}};"><!-- | |||
-->{{{group10}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list10padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list10style|}}};"><!-- | |||
-->{{{list10}}}<!-- | |||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#if:{{{group11|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group11style|}}};"><!-- | |||
-->{{{group11}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list11padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list11style|}}};"><!-- | |||
-->{{{list11}}}<!-- | |||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#if:{{{group12|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group12style|}}};"><!-- | |||
-->{{{group12}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list12padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list12style|}}};"><!-- | |||
-->{{{list12}}}<!-- | |||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#if:{{{group13|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group13style|}}};"><!-- | |||
-->{{{group13}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list13padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list13style|}}};"><!-- | |||
-->{{{list13}}}<!-- | |||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#if:{{{group14|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group14style|}}};"><!-- | |||
-->{{{group14}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list14padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list14style|}}};"><!-- | |||
-->{{{list14}}}<!-- | |||
--></dd><!-- | --></dd><!-- | ||
--></div><!-- | --></div><!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->{{#if:{{{group15|}}}|<!-- | |||
--><div style="display: table-row;"><!-- | |||
--><dt class="navbox-group" style="display: table-cell; font-family: inherit; {{{basestyle|}}}; {{{groupstyle|}}}; {{{group15style|}}};"><!-- | |||
-->{{{group15}}}<!-- | |||
--></dt><!-- | |||
--><dd class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}" style="display: table-cell; padding: {{{list15padding|{{{listpadding|0em 0.25em}}}}}}; {{{liststyle|}}}; {{{evenstyle|}}}; {{{list15style|}}};"><!-- | |||
-->{{{list15}}}<!-- | |||
--></dd><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
--></dl><!-- | --></dl><!-- | ||
-->}}<!-- | -->}}<!-- | ||
---Below--- | ---Below--- |
Latest revision as of 01:40, 15 November 2024
This template allows a navigational template to be set up relatively quickly by supplying it with navigational content, such as one or more lists of links. It comes equipped with default styles that should work for most navigational templates. Changing the default styles is not recommended, but is possible. Using this template is recommended to standardize navigational templates, and for ease of use.
Usage
Please remove the parameters that are left blank.
{{Navbox |name = {{subst:PAGENAME}} |title = |above = |body = |group1 = |list1 = |group2 = |list2 = ... |group10 = |list10 = |below = }}
Parameter list
The navbox uses lowercase parameter names, as shown in the box (at right). The mandatory name and title will create a one-line box if other parameters are omitted.
Notice "group1" (etc.) is optional, as are sections named "above/below".
The basic and most common parameters are as follows (see below for the full list):
name
- the name of the template.
title
- text in the title bar, such as: [[Widget stuff]].
body
- content to appear in the body section, a simplified alternative to group/list pairs (could be a list of overall wikilinks).
groupn
- the left-side text before list-n (if group-n omitted, list-n starts at left of box).
listn
- text listing wikilinks, often separated by middot templates, such as: [[A]]
{{·}}
[[B]]
Further details are explained below under section Parameter descriptions. See some alternate navbox formats under: Layout overview and Examples.
Parameter descriptions
The following is a complete list of parameters for using {{Navbox}}. In most cases, the only required parameters are name
, title
, and either body
or group1
.
Setup parameters
- name
- The name of the template, which is needed for the "v • d • e" ("view • discuss • edit") links to work properly on all pages where the template is used. You can enter
{{subst:PAGENAME}}
for this value as a shortcut. - state [
collapsed
] - Defaults to
uncollapsed
. A navbox withcollapsed
will start out collapsed. Otherwise, the navbox will be expanded. Often times, editors will want a default initial state for a navbox, which may be overridden in an article. Here is the trick to do this: In your intermediate template, create a parameter also named "state" as a pass-through like this: | state = {{{state<includeonly>|your_desired_initial_state</includeonly>}}}.
Content
- title
- Text that appears centered at the top of the navbox. It is usually the template's topic, i.e. a succinct description of the body contents. This should be a single line, but if a second line is needed, use
{{-}}
to ensure proper centering. - body
- If specified, text appears in the body of the navbox. Usually a list of links. A simplified alternative to group1, list1, etc. pairs.
- groupn
- (i.e. group1, group2, etc.) If specified, text appears on the left side of the body of the navbox.
- listn
- (i.e. list1, list2, etc.) If specified, text appears to the right of the corresponding groupn parameter. Usually a list of links.
- above
- Text displayed below the title and above the body.
- below
- Text displayed below the body (groups, lists and image).
Style parameters
Styles are generally not recommended as to maintain consistency among templates and pages in Wikipedia. However, the option to modify styles is given.
- style
- Specifies CSS styles to apply to the outer container.
- basestyle
- CSS styles to apply to the title, above, below, and group cells all at once. The styles 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.
- titlestyle
- Styles to apply to title, such as the titlebar's background color.
- bodystyle
- Styles to apply to body, or to the container around group and list content.
- groupstyle
- CSS styles to apply to the groupN cells.
- groupnstyle
- CSS styles to apply to a specific group, in addition to any styles specified by the groupstyle parameter.
- 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 liststyle parameter.
- listpadding
- A number and unit specifying the padding around each list. Default is padding of 0.25em on the left and right, and 0em on the top and bottom.
- 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 lists, respectively, in order to improve readability.
- 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 toeven
orodd
sets all rows to have that striping color. Setting tooff
disables automatic row striping. - abovestyle, belowstyle
- CSS styles to apply to the content specified via the above or below parameters.
Default styles
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.
style = background:#fdfdfd; text-align: center;
titlestyle = background:#ccccff; padding-left:6em; padding-right:6em;
abovestyle = background:#ddddff; padding-left:1em; padding-right:1em;
belowstyle = background:#ddddff; padding-left:1em; padding-right:1em;
groupstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:right;
liststyle = text-align:left;
evenstyle = background:#f7f7f7;
Since liststyle and oddstyle are transparent odd lists have the color of the main style, 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;
.
Layout overview
Layout generated by {{Navbox}} with group and list pairs, and without above and below parameters (gray list background color added for illustration only):
Layout generated by {{Navbox}} with body, above, and below parameters (gray list background color added for illustration only):
Examples
{{Navbox |name = Navbox/doc |title = [[Archetypes]] |body = [[Blaster]]{{dot}} [[Brute]]{{dot}} [[Controller]]{{dot}} [[Corruptor]]{{dot}} [[Defender]]{{dot}} [[Dominator]]{{dot}} [[Mastermind]]{{dot}} [[Scrapper]]{{dot}} [[Sentinel]]{{dot}} [[Stalker]]{{dot}} [[Tanker]]{{dot}} [[Arachnos Soldier]]{{dot}} [[Arachnos Widow]]{{dot}} [[Peacebringer]]{{dot}} [[Warshade]] }}
{{navbox| | name = Navbox/doc | title = [[Issues|Issue Releases]] | group1 = [[Cryptic Studios]] | list1 = [[Issue 1]]{{dot}} [[Issue 2]]{{dot}} [[Issue 3]]{{dot}} [[Issue 4]]{{dot}} [[Issue 5]]{{dot}} [[Issue 6]]{{dot}} [[Issue 7]]{{dot}} [[Issue 8]]{{dot}} [[Issue 9]]{{dot}} [[Issue 10]] | group2 = [[Paragon Studios]] | list2 = [[Issue 11]]{{dot}} [[Issue 12]]{{dot}} [[Issue 13]]{{dot}} [[Issue 14]]{{dot}} [[Issue 15]]{{dot}} [[Issue 16]]{{dot}} [[Issue 17]]{{dot}} [[Issue 18]]{{dot}} [[Issue 19]]{{dot}} [[Strike Pack|Issue 19.5]]{{dot}} [[Issue 20]]{{dot}} [[Incarnates Ascend|Issue 20.5]]{{dot}} [[Issue 21]]{{dot}} [[Media Blitz|Issue 21.5]]{{dot}} [[Issue 22]]{{dot}} [[Issue 23]]{{dot}} [[Issue 24]]{{dot}} [[Issue 25 (Paragon Studios)]] | group3 = [[Homecoming Team]] | list3 = [[Issue 25]]{{dot}} [[Issue 26]]{{dot}} [[Issue 27]] }}
Technical details
- This template uses CSS classes for most of its looks, thus it is fully skinnable.
- For more technical details see the talk page, the CSS classes in MediaWiki:common.css, and collapsible elements in MediaWiki.