Is there an easy way to give a MediaWiki wiki a specific background color?

We strive to provide pages of a specific category with a specific background color. Since each page in this category uses a specific template, we are ideally looking for a template change.

Can this be done?

+2


a source to share


2 answers


For MediaWiki 1.18 you need CSS and this code:

{{#css:
    #bodyContent { background-color: yellow; }
  body {
    background: navajowhite;
  }
}}

      

This will give the text portion of the page yellow and the rest (border) brown-ish .



For best results, place this in a template eg. {{Page Color}}, so it can be called with, for example, {{Page Color | red | yellow}}. The template code will be as follows:

{{#css:
    #bodyContent { background-color: {{{1|yellow}}}; }<!-- Page color -->
  body {
    background: {{{2|navajowhite}}};<!-- Border color -->
  }
}}

      

where 1 and 2 are parameters (page and border respectively) with default colors (yellow and brown).

+1


a source


Use the PageCSS extension , you can put css in your template, which will then be applied to the pages that it is.

Example:



 <css>
  #bodyContent { background-color: yellow; }
 </css>

      

+2


a source







All Articles