Template:Float/doc: Difference between revisions

m
35 revisions imported from wikipedia:Template:Float/doc
m (35 revisions imported from wikipedia:Template:Float/doc)
 
(17 intermediate revisions by 10 users not shown)
Line 1:
{{documentationDocumentation subpage}}
<!-- Please add categories to the /doc subpage, and interwikis at Wikidata (see Wikipedia:Wikidata) -->
<!---PLEASE ADD METADATA TO THE <includeonly> SECTION AT THE BOTTOM OF THIS PAGE--->
 
== Description ==
Use <code><nowiki>{{float}}</nowiki></code> to position items such as images so they do not affect the alignment or formatting of other items (e.g. text) nearby.
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 {{tl|align}}. For floating images, boxes, and other elements, see {{tl|stack}}.
: <code><nowiki>{{</nowiki>'''float'''|''top''= |''right''= |''bottom''= |''left''= |'''''item'''''}}</code>, where ''top'' and ''right'' default to zero.
: <code><nowiki>{{</nowiki>'''float'''|'''''item'''''}}</code> with default positioning ''top'':0, ''right'':0 (i.e. ''item'' floats on righthand side).
 
== Usage ==
''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 specified{{ndash}}e.g. <code><nowiki>{{</nowiki>float|top=2em|left=2em|width=10em|"Blah"}}</code>. Note that if any values other than zero for ''top'' and ''right'' are required, they need to be specified.
These are the standard usage:
* <code><nowiki>{{float|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the rightmost of a page/area.
* <code><nowiki>{{float|left|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the leftmost of a page/area.
 
More configuration:
===Examples===
* <code><nowiki>{{float |width= |height= |top= |right= |bottom= |left= |</nowiki>{{bigger|{{smallcaps|item}}}}}}</code>
; Example 1
 
One-line [[Template:Navbox|navbox]] using its image parameter:
<code>{{bigger|{{smallcaps|item}}}}</code> is required. You must specify what text or element to float or it will throw an error.
 
All parameters are optional. The parameters {{para|width}} and {{para|height}} are to indicate the width/height of the <code><nowiki><div></nowiki></code> element. <!--Unnecessary?: Note that if any values other than zero for ''top'' and ''right'' are required, they need to be specified.-->
 
The optional parameters {{para|top}}, {{para|right}}, {{para|bottom}} and {{para|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, <code><nowiki>{{float |top=2.0em |left=2px |width=10em | the content to float}}</nowiki></code>.
 
=== 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|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) ===
One-lineThis is a [[Template:Navbox|navbox]] using its image parameter:
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 25 ⟶ 46:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |showhide=left |title=CodeThe forcode Exampleused 1|togglein =the leftabove example}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
Line 41 ⟶ 62:
}}
</pre>
{{hiddenHidden end}}
 
=== Example 2 (with float) ===
SameWe navboxuse using <code><nowiki>{{tlf|float}}</nowiki></code> instead of the navbox's image parameter:
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|[[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]]
}}
{{Hidden begin |showhide=left |title=The code used in the above example}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|[[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 (with float and custom values) ===
; Example 2
We use {{tlf|float}} with a custom value of {{para|top}} this time:
Same navbox using <code><nowiki>{{float}}</nowiki></code> instead of the image parameter:
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|top=-0.1em5em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
Line 57 ⟶ 109:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |showhide=left |title=CodeThe forcode Exampleused 2|togglein =the leftabove example}}
<pre>
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|top=-0.1em5em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
Line 72 ⟶ 124:
}}
</pre>
{{hiddenHidden end}}
 
=== Alternatives for navigational boxes ===
; Example 3
SameWe navbox usinguse its image parameter and liststyle with padding-left set to the image width:
{{Navbox
| name = Float/doc
Line 90 ⟶ 142:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{hiddenHidden begin |showhide=left |title=CodeThe forcode Exampleused 3|togglein =the leftabove example}}
<pre>
{{Navbox
Line 107 ⟶ 159:
}}
</pre>
{{hiddenHidden end}}
 
== See also ==
Note how the links in the second two examples are centered relative to the whole template, unlike in the first example.
* {{tl|align}}
* {{tl|stack}}
* {{tl|clear}}
 
<includeonly>{{sandbox other||
<!-- Add categories below this line, and interwikis at Wikidata -->
[[Category:Wikipedia formatting and functionPositioning templates]]
[[pt:Predefinição:Float]]
}}</includeonly>
[[tr:Şablon:Float]]
</includeonly>