Template:Float/sandbox
![]() | This is the template sandbox page for Template:Float (diff). See also the companion subpage for test cases. |
Contents
Description
It is used to position text or elements to the rightmost/leftmost of a page/area, without changing the alignment or formatting of other text and elements nearby.
For aligning text in general, see {{align}}. For floating images, boxes, and other elements, see {{stack}}.
Usage
These are the standard usage:
{{float|Template:Smallcaps}}
floats Template:Smallcaps on the rightmost of a page/area.{{float|left|Template:Smallcaps}}
floats Template:Smallcaps on the leftmost of a page/area.
More configuration:
{{float |width= |height= |top= |right= |bottom= |left= |Template:Smallcaps}}
Template:Smallcaps
is required. You must specify what text or element to float or it will throw an error.
All parameters are optional. The parameters |width=
and |height=
are to indicate the width/height of the <div>
element.
The optional parameters |top=
, |right=
, |bottom=
and |left=
are to indicate how far from their respective positions the item is to be positioned.
Any established HTML/CSS units may be used, for example, {{float |top=2.0em |left=2px |width=10em | the content to float}}
.
Beware
Beware when using this template in navboxes. Please ensure whatever it floats (e.g. an image) does not float over other elements or text, even after the navbox is resized.
To align centered lists in a navbox with an image, see the alternatives for navigational boxes section below.
Examples
Note how the links in the second two examples are centered relative to the whole template, unlike those in the first example.
Example 1 (without float)
This is a navbox using its image parameter:
Example 2 (with float)
We use {{float}} instead of the navbox's image parameter:
Example 3 (with float and custom values)
We use {{float}} with a custom value of |top=
this time:
We use its image parameter and liststyle with padding-left set to the image width:
See also
The above documentation is transcluded from Template:Float/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |