Help:Infoboxes/CSS

Portable infoboxes can be themed quite easily by local administrators using a wiki's community CSS.

Without customization, portable infobox theming takes cues from your community's Theme Designer settings, particularly the article background color, accent color, and link color.

Infobox themes and types
The default infobox theming can be overridden using local community CSS, and using the type, theme, or theme-source attributes on the infobox tag will make it easy to target specific infobox templates using classes.


 * The type attribute is used to specify a logical type (what an infobox is describing), but can also be used as a CSS class.
 * The theme attribute is used to specify a custom CSS class for the infobox template.
 * The theme-source attribute allows you to vary the CSS class via a template parameter.

Using "type"
For example, type="character" will add a class called type-character to the infobox HTML, which can then be customized using CSS:

As an example, the code below could then be used to change the secondary background color (the background color of the infobox title and headers) of all character infoboxes to maroon:

Using "theme"
For example, theme="delta" will add a class called pi-theme-delta to the infobox HTML, which can then be customized using CSS:

As an example, the code below could then be used to change the secondary background color of all delta-themed infoboxes to navy blue:

If theme= is left unspecified, it will default to theme="wikia" and the class pi-theme-wikia will be added to the infobox.

Using "theme-source"
For example, theme-source="location" means that, when location is specified in an article's infobox, it will use the value of it to form a class name.

For example:

If you want to change the secondary background of the infoboxes for all locations in Africa, you would do then something like this:

Note that class names are case-sensitive, so be careful about what you allow users to enter as the value of the theme-source parameter. In this case illustrated above, a value of "africa" would not trigger the desired style changes.

Advanced theme notes

 * If both theme and theme-source are used, both will supply CSS properties.
 * Spaces in the values of theme and theme-source are converted to hyphens, meaning only a single class can be added.
 * If no theme is specified, pi-theme-wikia will be added instead.

Main classes
These classes help you update the styling of specific tags:
 * Title


 * Header


 * Navigation


 * Group


 * Data tag


 * Data Value


 * Data Label


 * Image


 * Image Caption


 * Image Gallery


 * Panel Tabs Element


 * Panel Tab Group


 * Panel Tab


 * Panel Tab Content

Helper classes
Portable infoboxes contain a variety of design-specific helper classes to help you easily update the overall styling:
 * Overall infobox background


 * Title and header backgrounds


 * Data value font styling


 * Header, data label, and navigation font styles


 * Padding around each infobox element (title, headers, and each label/data pair)


 * Infobox element border color (entire infobox, captions, groups, label/data pairs, and tab content groups)

Note: this is not an exhaustive list of available classes - more are listed within Help:Infoboxes/Tags.

Sample code snippets
Change infobox width:

Change infobox background color:

Change infobox headers and navigation background:

Change infobox elements border color:

Change infobox elements paddings:

Change infobox data values font size:

Change infobox headers, labels, and navigation values font size:

Change infobox title font size:

Change label column width:

Select for custom theme "oblivion", then tweak caption font size:

Change background color of tabs for images

Advanced
Normally, if you need to change the styling for a specific theme you would write something like this:

However, when a CSS class is on the same element as another and you need to select for both, leave no space between the classes. For example,  is on the same   element as the theme class  and the general portable infobox class, so CSS that changes the background for that theme would be:

Individual elements can be styled independently using data-attributes as selectors. For example, all Portable Infobox elements that have an input of source will now render in HTML with that parameter name in a data-attribute, such as data-source="ATK". This will allow you to write CSS or jQuery selectors such as .pi-item[data-source=ATK] to style and identify individual items. Used in combination with type, this should eliminate the need for nth-of-type style selection and opens up other possibilities for design and interactivity.

The name attribute on an item allows explicit selection of elements whether they accept a source input or not, including identification of, , , , , and. Much like the data-source data-attribute, can be selected as .pi-item[data-item-name=bar].

de:Hilfe:Infoboxen/CSS es:Ayuda:Infoboxes/CSS fi:Ohje:Tietolaatikot/CSS fr:Aide:Infoboxes/CSS it:Aiuto:Infobox/CSS ja:ヘルプ:インフォボックス/CSS ko:도움말:정보상자/CSS pl:Pomoc:Infoboksy/CSS pt:Ajuda:Infoboxes/CSS ru:Справка:Инфобоксы/CSS tr:Yardım:Bilgi kutuları/CSS uk:Довідка:Інфобокси/CSS vi:Trợ giúp:Hộp thông tin/CSS zh:Help:訊息框/CSS