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

We're looking to give pages in a specific category a specific background colour. Since every page in this category makes use of a specific template, we're ideally looking for a template change.

Can this be done?

Upvotes: 2

Views: 4494

Answers (2)

For the MediaWiki 1.18, you only need CSS and this code:

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

This will give the part of the page with text a yellow colour and the rest (border) a brown-ish colour.

For best results, put this in a template, e.g. {{Page colour}}, so that it can be called with, e.g. {{Page color|red|yellow}}. The template code will then be:

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

where 1 & 2 are parameters (page and border respectively) with default colours (yellow and brownish).

Upvotes: 2

Adrian Archer
Adrian Archer

Reputation: 2323

Use the PageCSS extension, you should be able to put the css in your template, which would then apply to the pages it is on.

example:

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

Upvotes: 2

Related Questions