|
Cookbook /
BackgroundImagesSummary: How to add background images to divisions, tables & cells
Status: Stable
Version: 1
Prerequisites: pmwiki-2.0
Maintainer:
Categories: Images
Votes:
QuestionHow can I use background images for divisions, tables and table cells? Answerstyle='background-image...'The url location for use as a background image can be included in a style declaration as This can be done in markup for $FmtPV['$PubDirUrl'] = '$GLOBALS["PubDirUrl"]';
Then use it in the url for the background image for instance like url({$PubDirUrl}/images/image.file)
Note also that you cannot use Attach:image.ext Δ syntax inside the url. Examples:A division with a background image. A relative path is used.
Markup (:background:)To apply background-image styling to divisions not defined on the wiki page, like the whole wikitext division, you can use a custom markup: Set in config.php:
Markup('background', 'directive',
'/\\(:background(\\s.*?)?:\\)/e',
"Background(\$pagename, ParseArgs(PSS('$1')))");
function Background ($pagename, $opt) {
global $HTMLStylesFmt;
foreach($opt as $divname => $value) {
$HTMLStylesFmt[] = " #$divname { background:$value } \n ";
}
};
Usage:
divname is any division name, like wikitext, or as used in Gemini and Fixflow skins: content, sidebar etc (check your skin tmpl for divs, there are big variations in naming divs) without the leading # sign. Background attributes are any css attr. for background (including background image url), like color-names, color-codes,
url(http://site/path/bgimage),
no-repeat, repeat-x, repeat-y, center etc.
Use attributes as words without commas. Example:
You can have several divnames in the markup, like content=#fed sidebar=#def etc. Notes, Comments, QuestionsThe background markup has some potential for misuse, as it can render the page unusable, if backgrounds are chosen which makes the page unreadable. Similar caution applies to use of absolutely positioned divisions. How can I set that background image for a single wiki page (ie for the <html> tag)? Hmmm, do you mean to the whole page? It depends if the skin template has a wrapper division. If so you could use that (in FixFlowSkin and GeminiSkin you can use 'wrapper'). In css you normally use the body tag, but this won't work with the above markup, since the markup puts a # symbol in front of the div name. you could try and change the markup, write $HTMLStylesFmt[] = " $divname { background:$value } \n "; , i.e. without the #. and then use div names with the # if you need them, like #content, and try body for a whole page background. Note this is untested. ~HansB
This is how I got the background to work for the whole page: could use a little more help!
See Also
ContributorsCategory: Images
SandboxBackground image opacity is also applied to the text, making it less usefull: It's a BACKGROUND image... at the back of the page content. Why would you apply opacity to it? Just prepare the base image with the require amount of fading. A division with a background image. |