The {div} macro wraps content in a div tag with optional class and styles...
The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it.
Unlike the span tag, a div stretches to fill the available width of it's containing element making it ideal for use with blocks of content such as a whole paragraph.
This macro is primarily designed for use with the style macro as this would make it easy to apply custom styles to your content. Alternatively you can specify specific styles for each use of the macro.
Add the macro to your page as follows:
{div:class=x y z|style=css}
your content
{div}
Parameters
At least one parameter must be specified You must specify at least one of the parameters below for this macro to work.
Parameter
Required
Default
Notes
class
The class to associate with the div. Multiple classes can be specified by separating them with spaces.
style
An optional inline style sheet to apply to an individual div tag.
This plug-in is available without cost for both commercial and non-commercial purposes. However, if you have found it to be useful, particularly within a commercial environment, please consider making a donation to the author. This will encourage continued development of this and other plug-ins, as well as speeding up the response for your latest maintenance request.
If you wish to donate, it can be done easily with a credit card or bank transfer using PayPal. No account sign-up is required for credit or debit card payments.
The {search-box macro} is released under the BSD License.
This macro has been tested by Adaptavist with Confluence 1.4.1, 1.4.3, 1.4.4, 2.0, 2.1 and 2.1.2.
It is usually pre-installed with Builder accounts. To install it on your own Confluence installation, please see Content Formatting Macros
Adaptavist maintain a JIRA Project for tracking bug reports and feature requests for this macro. The currently reported items are shown below:
jiraissues: Could not download[ http://jira.adaptavist.com/secure/IssueNavigator.jspa?view=rss&pid=10080&component=10141&statusIds=1&statusIds=3&statusIds=4&statusIds=5&sorter/field=updated&sorter/order=DESC&tempMax=25&reset=true&decorator=none] : caused by : Circular redirect to 'http://jira.adaptavist.com:80/secure/IssueNavigator.jspa'
To define a custom class, use the "class" parameter:
{div:class=warningMacro}This is a div example{div}
This will add the following HTML to your page:
<div class="warningMacro">This is a div example</div>
Resulting in:
This is a div example
As you can see, we've hijacked the "warningMacro" class used by the warning macro to put a red border and background on the text contained within the div.
Inline Styles
In our last example, we applied a background and border to some content, but there wasn't any padding between the border and the text - to rectify that we can use an inline style (and we'll also make the border a bit bigger so you can see how to add multiple inline styles):
{div:class=warningMacro|style=padding:3px;border-width:5px}This is a div example{div}
This will add the following HTML to your page:
<div class="warningMacro" style="padding:3px;border-width:5px">This is a span example</div>
Resulting in:
This is a div example
Hints and Tips
If you are using the same inline style several times, create a stylesheet for the class using either the style macro or the CSS Custom Styles feature of the Builder theme.
Can you please provide an example with multiple inline style decorations? I understand we can use a style sheet but...
Example (that's not working):
\{div:style=background:#F0F0F0|border:1px solid #333399|left:1em|right:1em\} loremipsum \{div\}Is only the first style declaration valid?
Thanks,
Liberty Miller, 2006-12-04
The style param is the same as the standard HTML style attribute so you need something like:
{div:style=background:#F0F0F0;border:1px solid #333399;left:1em;right:1em} loremipsum {div}The CSS atribs are split by semi-colons, not pipes.
I'm having trouble nesting the div macro. The nested div macro seems to close out it's parent before it acts on the text. We are using
I see the FAQ above and have supplied a style parameter on each one. Does the macro support nesting?
Here is an example:
{div:style=width:100%}
{div:style=background-color:lightgreen}header{div}
{div}
Confluence doesn't support nesting of macros, unfortunately. That's why we added div2, div3 and div4, etc., macros in to the plugin
{div} {div2}div 2 content{div2} etc. {div}Thanks so much for your quick reply. The div2 and div3 macros work fantastic. I will have to get our Wiki team to document them.