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
No edit summary
m (35 revisions imported from wikipedia:Template:Float/doc)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE, and INTERWIKIS IN WIKIDATA -->
<!-- Please add categories to the /doc subpage, and interwikis at Wikidata (see Wikipedia:Wikidata) -->
{{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 ==
== 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}}.


== Usage ==
== Usage ==
These are the standard usage:
* <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|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the rightmost of a page/area.
* <code><nowiki>{{float |top= |right= |bottom= |left= |width= |</nowiki>{{bigger|{{smallcaps|item}}}}}}</code>
* <code><nowiki>{{float|left|</nowiki>{{bigger|{{smallcaps|item}}}}}}</code> floats {{smallcaps|item}} on the leftmost of a page/area.

More configuration:
* <code><nowiki>{{float |width= |height= |top= |right= |bottom= |left= |</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.
{{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.-->


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


=== Example 1 ===
=== Example 1 (without float) ===
One-line [[Template:Navbox|navbox]] using its image parameter:
This is a [[Template:Navbox|navbox]] using its image parameter:
{{Navbox
{{Navbox
| name = Float/doc
| name = Float/doc
Line 31: Line 46:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
{{Hidden begin |showhide=left |title=Code for Example 1}}
{{Hidden begin |showhide=left |title=The code used in the above example}}
<pre>
<pre>
{{Navbox
{{Navbox
Line 49: Line 64:
{{Hidden end}}
{{Hidden end}}


=== Example 2 ===
=== Example 2 (with float) ===
Same navbox using {{tlf|float}} instead of the image parameter:
We use {{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
{{Navbox
| name = Float/doc
| name = Float/doc
Line 56: Line 102:
| title = [[Imperial Japanese Navy]]
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| listclass = hlist
| list1 = {{float|top=-0.1em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
| list1 = {{float|top=0.5em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[Battles of the Imperial Japanese Navy|Battles]]
Line 63: Line 109:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
{{Hidden begin |showhide=left |title=Code for Example 2}}
{{Hidden begin |showhide=left |title=The code used in the above example}}
<pre>
<pre>
{{Navbox
{{Navbox
Line 70: Line 116:
| title = [[Imperial Japanese Navy]]
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| listclass = hlist
| list1 = {{float|top=-0.1em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
| list1 = {{float|top=0.5em|[[File:Naval Ensign of Japan.svg|24px|border|Naval Ensign of Japan]]}}
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Imperial Japanese Navy admirals|Admirals]]
* [[Battles of the Imperial Japanese Navy|Battles]]
* [[Battles of the Imperial Japanese Navy|Battles]]
Line 81: Line 127:


=== Alternatives for navigational boxes ===
=== Alternatives for navigational boxes ===
Same navbox using its image parameter and liststyle with padding-left set to the image width:
We use its image parameter and liststyle with padding-left set to the image width:
{{Navbox
{{Navbox
| name = Float/doc
| name = Float/doc
Line 96: Line 142:
* [[List of weapons of the Japanese Navy|Weapons]]
* [[List of weapons of the Japanese Navy|Weapons]]
}}
}}
{{Hidden begin |showhide=left |title=Code for this alternative navigational box}}
{{Hidden begin |showhide=left |title=The code used in the above example}}
<pre>
<pre>
{{Navbox
{{Navbox
Line 120: Line 166:
* {{tl|clear}}
* {{tl|clear}}


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
<includeonly>{{sandbox other||
| <!-- ADD CATEGORIES HERE, and INTERWIKIS IN WIKIDATA -->
<!-- Add categories below this line, and interwikis at Wikidata -->
[[Category:Positioning templates]]
[[Category:Positioning templates]]
}}</includeonly>
}}</includeonly>

Latest revision as of 16:10, 25 June 2021

Description[edit source]

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[edit source]

These are the standard usage:

  • {{float|item}} floats item on the rightmost of a page/area.
  • {{float|left|item}} floats item on the leftmost of a page/area.

More configuration:

  • {{float |width= |height= |top= |right= |bottom= |left= |item}}

item 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[edit source]

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[edit source]

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)[edit source]

This is a navbox using its image parameter:

The code used in the above example
{{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 (with float)[edit source]

We use {{float}} instead of the navbox's image parameter:

The code used in the above example
{{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]]
}}

Example 3 (with float and custom values)[edit source]

We use {{float}} with a custom value of |top= this time:

The code used in the above example
{{Navbox
| name = Float/doc
| state = uncollapsed
| title = [[Imperial Japanese Navy]]
| listclass = hlist
| list1 = {{float|top=0.5em|[[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]]
}}

Alternatives for navigational boxes[edit source]

We use its image parameter and liststyle with padding-left set to the image width:

The code used in the above example
{{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]]
}}

See also[edit source]