Template:Float/doc: Difference between revisions

m
35 revisions imported from wikipedia:Template:Float/doc
(category)
m (35 revisions imported from wikipedia:Template:Float/doc)
 
(5 intermediate revisions by 3 users not shown)
Line 1:
{{Documentation subpage}}
<!-- Please add categories to the /doc subpage, and interwikis at Wikidata (see Wikipedia:Wikidata) -->
<!---PLEASE ADD CATEGORIES WHERE INDIACTED AT THE BOTTOM OF THIS PAGE--->
{{Notice |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}}.}}
 
== Description ==
Use {{tl|float}} to "float" items{{spaced ndash}}i.e. position them{{spaced ndash}}so they do not affect the alignment or formatting of other items (such as 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>{{float|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the righthand edge of a page/area.
* <code><nowiki>{{float|left|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the lefthand edge of a page/area.
* <code><nowiki>{{float |top= |right= |bottom= |left= |width= |</nowiki>{{bigger|{{smallcaps|item}}}}}}</code>
 
== Usage ==
{{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 (for example, <code><nowiki>{{float |top=2.0em |left=2px |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.-->
These are the standard usage:
* <code><nowiki>{{float|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the righthand edgerightmost of a page/area.
* <code><nowiki>{{float|left|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the lefthand edgeleftmost of a page/area.
 
More configuration:
===Examples===
* <code><nowiki>{{float |width= |height= |top= |right= |bottom= |left= |width= |</nowiki>{{bigger|{{smallcaps|item}}}}}}</code>
 
<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
Line 29 ⟶ 46:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{Hidden begin |showhide=left |title=CodeThe forcode Exampleused 1in the above example}}
<pre>
{{Navbox
Line 47 ⟶ 64:
{{Hidden end}}
 
;=== Example 2 (with float) ===
SameWe navbox usinguse {{tlf|float}} 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) ===
We use {{tlf|float}} with a custom value of {{para|top}} this time:
{{Navbox
| name = Float/doc
Line 54 ⟶ 102:
| 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 61 ⟶ 109:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{Hidden begin |showhide=left |title=CodeThe forcode Exampleused 2in the above example}}
<pre>
{{Navbox
Line 68 ⟶ 116:
| 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 78 ⟶ 126:
{{Hidden end}}
 
=== Alternatives for navigational boxes ===
SameWe navbox usinguse its image parameter and liststyle with padding-left set to the image width:
{{Navbox
| name = Float/doc
Line 94 ⟶ 142:
* [[List of weapons of the Japanese Navy|Weapons]]
}}
{{Hidden begin |showhide=left |title=CodeThe code used in the above example}}
<pre>
{{Navbox
Line 116 ⟶ 164:
* {{tl|align}}
* {{tl|stack}}
* {{tl|clear}}
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox other||
<!-- Add categories below this line, and interwikis at Wikidata -->
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
[[Category:Positioning templates]]
}}</includeonly>