Template:Divbox/doc

This template can be used to create simple, flexible coloured text background.

Please note that this is intended to be a decorative template and not for use on the general encyclopedia. It will not display on articles.

Usage
The parameter radius may be added for rounded corners using standard units, for example radius=8px.

Available styles
amber black bloodred blue brown forest gold

gray green navy none orange plain purple

lilac red <div style="; width:5em; float:left; margin:.3em">white <div style="; width:5em; float:left; margin:.3em">yellow <div style="; width:5em; float:left; margin:.3em">fawn <div style="; width:5em; float:left; margin:.3em">tt <div style="; width:5em; float:left; margin:.3em">simar

<div style="; width:4em; float:left; margin:.3em">greenv <div style="; width:5em; float:left; margin:.3em">grayh <div style="; width:5em; float:left; margin:.3em">email <div style="; width:8em; float:left; margin:.3em">double <div style="; width:8em; float:left; margin:.3em">wordperfect <div style="; width:5em; float:left; margin:.3em">ivory


 * Notes
 * The color names are case-dependent; they will not work if upper-case letters are used.
 * plain, double, tt and none inherit the page background colour whilst white forces a pure white background.

Examples

 * Code
 * Result


 * Code
 * Result

Purpose
TechInfoDepot abounds in boxed templates, such as:


 * &#123;&#123;delete&#125;&#125;
 * &#123;&#123;tfd&#125;&#125;
 * &#123;&#123;GFDL&#125;&#125;
 * &#123;&#123;current&#125;&#125;
 * &#123;&#123;FAC&#125;&#125;

Boxes may not always be appropriate; they can be obtrusive. But when boxes are used, they are generally formatted ad hoc. This leads to inconsistencies.

&#123;&#123;divbox&#125;&#125; provides a straightforward method of presenting any text within a box. Colors are selected using a private style keyword, which sets both box border and background, already chosen to work together, in a visual sense.

The keyword  puts your content inside an invisible box. This is available to offer the identical box model for your content, without a visible box.

This template may be used within another template; or as part of another page.

Technical
This template takes its first parameter and uses it to construct an instance of one of its component templates divstyle (see list); this emulates a case statement. New divbox styles may be created with minimal effort. All of the (component) templates contain only the style parameters of the box.

A &lt;div&gt; is generated with class="boilerplate metadata" and id=(second parameter); thus id is the same as the displayed title. A user's CSS may override the entire class.

Usage

 * keyword: private style keyword; chooses colors for box
 * title: plain text; appears strong and centered at top
 * content: any text, including markup; your content

The box has the full available width. In the examples below the width is reduced by the fact that the boxes are placed in a table.


 * Don't forget to close the template with double braces ("}}")!


 * If you want to omit a centered title for the box, you must use two pipes ("||") instead of one before your box content. Still, it is not recommended that you omit any title.


 * You must always supply the first parameter. This is a private style keyword from the list:

Remember these are private style keywords, not HTML colors. You must use lowercase only. The keyword  puts your content inside an invisible box.

Using subst: with this template
The  atom may be used with divbox. This may be highly desirable. Note that  does not take effect in preview, but only after saving a page. The template's inclusion is replaced by the code of the template itself, which will continue to write the box as before, but without an additional server call.

Since divbox itself calls a template based on your choice of style keyword, you will find that even after saving an instance of use with  there remains a "live" call to the underlying style template. This means that viewing the page risks a server call to the style template, but also means that changes to the style template automatically propagate to all pages where it is used. This way, all divbox-type boxes, wherever they are in the project, keep the same consistent look.

Just paste in your content and, when you're finished, be sure to close the template call with.

Since the contents are given in the form of two parameter values, for the content you may place within divbox, the restrictions on parameter values apply. For example, if you put content that includes template calls, divbox cannot tell where its last parameter ends.

If the contents do not satisfy the restrictions, insert this code in your page first:

That is, choose your style and title as usual (or omit the title with two pipes), but instead of actual content, write "DUMMYCONTENT". Then, save the page and reopen it for editing. You'll see the box code in all its gory detail, and the placeholder DUMMYCONTENT, followed by the HTML division closing tag. Now, you may simply replace DUMMYCONTENT with your content, save, and move on. Since almost anything may be placed within division tags, this should not break no matter what you do.

Making new divbox styles
I'd rather hope you were able to find joy within the existing set of styles, but if not, you can create new ones. Follow these instructions to be sure your new style will "play nice" with &#123;&#123;divbox&#125;&#125;. Note that this requires some understanding of CSS.


 * 1) Experiment in a drawing program, such as GraphicConverter or Adobe Photoshop, and decide what colors you want for your new box style. You need to find out the HTML color codes for each color.
 * 2) Open an existing box style template, such as &#123;&#123;divbox/style/red&#125;&#125;. Copy out the code.
 * 3) Create a new box style template page. It must be located in main Template namespace and must be named , where "XXXXX" is your new style name.
 * 4) Paste in the "borrowed" code and replace the color codes with your new, chosen colors. Save the new template.
 * 5) Return to this Talk page and add your new style to this documentation. Remember, a job's not over until the paperwork is done!

Note that you may even change the division box margins and paddings. This is not recommended. There are a couple of good reasons for specifying these values, and in these units. Most users who "roll their own" make choices with unintended consequences; {divbox} is meant to help you avoid these pitfalls.