Template:Float/doc: Difference between revisions

update (primarily to introduce {{float|left|...}})
m (Detele interwiki -> wikidata)
(update (primarily to introduce {{float|left|...}}))
Line 1:
{{documentationDocumentation subpage}}
<!---PLEASE ADD METADATA TO THE <includeonly> SECTION AT THE BOTTOM OF THIS PAGE--->
{{noticeNotice |Take care when using this template in navboxes to ensure that whatever it is used to float (e.g. an image) does not float over other elements or text if{{\}}when the navbox is resized. To align centered lists in a navbox with an image, see the [[#Alternatives for navigational boxes|alternatives for navigational boxes]] section below. For aligning text in general, see {{tl|align}}. For floating images, boxes, and other elements, see {{tl|stack}}.}}
 
Use <code><nowiki>{{tl|float}}</nowiki></code> to position"float" items{{spaced suchndash}}i.e. asposition imagesthem{{spaced ndash}}so they do not affect the alignment or formatting of other items (e.g.such as text) nearby.
 
:* <code><nowiki>{{float|</nowiki>'''float'''{{bigger|''top''= {{smallcaps|''right''= |''bottom''= |''left''= |'''''item'''''}}}}}}</code>, wherefloats ''top''{{smallcaps|item}} andon ''right''the defaultrighthand toedge zeroof a page/area.
:* <code><nowiki>{{float|left|</nowiki>'''float'''{{bigger|{{smallcaps|'''''item'''''}}}}}}</code> withfloats default{{smallcaps|item}} positioningon ''top'':0,the ''right'':0lefthand (i.e.edge ''item''of floatsa on righthand side)page/area.
* <code><nowiki>{{float |top= |right= |bottom= |left= |width= |</nowiki>{{bigger|{{smallcaps|item}}}}}}</code>
 
''{{para||{{bigger|{{smallcaps|item''}}}}}} is the only required parameter. The optional parameters ''top'', ''right'', ''bottom'', and ''left'' indicate how far from their respective positions the ''item'' is to be positioned. The ''width'' of the item may also be specified. Any established HTML/CSS units may be used so long as they are specified{{spaced ndash}}e.g.(for example, <code><nowiki>{{</nowiki>float |top=2em2.0em |left=2em2px |width=10em |"Blah"}}</nowiki></code>). <!--Unnecessary?: Note that if any values other than zero for ''top'' and ''right'' are required, they need to be specified.-->
 
===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
One-line [[Template:Navbox|navbox]] using its image parameter:
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 28 ⟶ 29:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |showhide=left |title=Code for Example 1|toggle = left}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 44 ⟶ 45:
}}
</pre>
{{hiddenHidden end}}
 
; Example 2
Same navbox using <code><nowiki>{{tlf|float}}</nowiki></code> instead of the image parameter:
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 60 ⟶ 61:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |showhide=left |title=Code for Example 2|toggle = left}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 75 ⟶ 76:
}}
</pre>
{{hiddenHidden end}}
 
== Alternatives for navigational boxes ==
Line 93 ⟶ 94:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |titleshowhide=Codeleft for Example|toggle title= leftCode}}
<pre>
{{Navbox
Line 110 ⟶ 111:
}}
</pre>
{{hiddenHidden end}}
 
<includeonly>