Template:Float/doc: Difference between revisions

Nothing to hide, but nothing to show you either.
Jump to navigation Jump to search
Content added Content deleted
m (wikify and add an example)
No edit summary
Line 10: Line 10:


===Examples===
===Examples===
; Example 1
'''One-line [[Template:Navbox|navbox]] using its image parameter:'''
'''One-line [[Template:Navbox|navbox]] using its image parameter:'''
{{Navbox
{{Navbox
Line 24: Line 25:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
{{hidden begin|title=Code for Example 1|toggle = left}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| image = [[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]
| list1 =
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
</pre>
{{hidden end}}


; Example 2
'''Same navbox using <code><nowiki>{{float}}</nowiki></code>:'''
'''Same navbox using <code><nowiki>{{float}}</nowiki></code> instead of the image parameter:'''
{{Navbox
{{Navbox
| name = Float/doc
| name = Float/doc
Line 38: Line 57:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
{{hidden begin|title=Code for Example 2|toggle = left}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|top=-0.1em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
</pre>
{{hidden end}}


; Example 3
'''One-line [[Template:Navbox|navbox]] using its image parameter and liststyle with padding-left set to the image width:'''
'''Same navbox using its image parameter and liststyle with padding-left set to the image width:'''
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| image = [[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]
| liststyle = padding-left: 24px
| list1 =
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hidden begin|title=Code for Example 3|toggle = left}}
<pre>
{{Navbox
{{Navbox
| name = Float/doc
| name = Float/doc
Line 54: Line 106:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
</pre>
{{hidden end}}


Note how the links in the second two examples are centered relative to the whole template, unlike in the first example.
Note how the links in the second two examples are centered relative to the whole template, unlike in the first example.

Revision as of 22:08, 25 January 2012

Use {{float}} to position items such as images so they do not affect the alignment or formatting of other items (e.g. text) nearby.

{{float|top= |right= |bottom= |left= |item}}, where top and right default to zero.
{{float|item}} with default positioning top:0, right:0 (i.e. item floats on righthand side).

item is the only required parameter. The optional parameters top, right, bottom, left indicate how far from their respective positions the item is to be positioned. The width of the item may also be specified. Any units may be used so long as they are specifiedTemplate:Ndashe.g. {{float|top=2em|left=2em|width=10em|"Blah"}}. Note that if any values other than zero for top and right are required, they need to be specified.

Examples

Example 1

One-line navbox using its image parameter:

Code for Example 1
{{Navbox
| name  = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| image = [[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]
| list1 =
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
Example 2

Same navbox using {{float}} instead of the image parameter:

Code for Example 2
{{Navbox
| name  = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|top=-0.1em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
Example 3

Same navbox using its image parameter and liststyle with padding-left set to the image width:

Code for Example 3
{{Navbox
| name      = Float/doc
| state     = uncollapsed
| title     = [[Imperial Japanese Navy]]
| listclass = hlist
| image     = [[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]
| liststyle = padding-left: 24px
| list1     =
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[List of ships of the Japanese Navy|Ships]]
* [[List of aircraft of the Japanese Navy|Aircraft]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}

Note how the links in the second two examples are centered relative to the whole template, unlike in the first example.