Template:Center/doc: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Created page with "A simple centering template. Equivalent to <code><nowiki><center> ... </center></nowiki></code>. == Usage == {{tlx|center|Text or images to be centered here}} <includeonly>...")
 
(Improve depth of documentation and add examples of using style parameter to declare more CSS properties)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
A simple centering template. Equivalent to <code><nowiki><center> ... </center></nowiki></code>.
{{Documentation subpage}}
<!-- Add categories where indicated at the bottom of this page -->
 
== Description ==
This template's purpose is to center any elements supplied to it on the page, regardless of the browser used and the width of the display or window. This is done by wrapping the contents in &lt;/div&gt;&lt;div&gt; HTML5 tags that have the following CSS 3.0 properties:<br /><code>width: auto; margin-left: auto; margin-right: auto;</code>


== Usage ==
== Usage ==
{{tlx|center|Text or images to be centered here}}
Simply place any valid Wikitext you wish to appear centered as the contents of the (only) unnamed parameter, as in...
 
<big>'''<code>&#123;&#123;Center|Elements (text, images, etc.) to be centered here&#125;&#125;</code>'''</big>
 
...which is rendered by the parser as:
 
{{Center|Elements (text, images, etc.) to be centered here}}
 
=== Additional CSS properties ===
This template does have one named parameter, '''<code>style</code>''', which can be used to pass additional CSS properties to the wrapping &lt;div&gt; tags. The  properties should be well-formed CSS 3.0, with colon-delimited property names and all values terminated with a semicolon. As an example, if it was desired to have the template's output be double-spaced below the preceding text and in a larger, bold font, it would look like...
 
<big>'''<code>&#123;&#123;Center|style&#61;margin-top: 2em; font-size: larger; font-weight: bold;|Elements (text, images, etc.) to be centered here&#125;&#125;</code>'''</big>
 
...which is rendered as:
 
{{Center|style=margin-top: 2em; font-size: larger; font-weight: bold;|Elements (text, images, etc.) to be centered here}}
 
=== Bare HTML tags ===
To do this without a template, simply use the following HTML code, replacing the '...' with any standard Wikitext you want to appear centered on the page (multiple lines are acceptable, too):
<syntaxhighlight lang="HTML" style="margin: 1.5em 10em 1em 2.5em;"><div class="center" style="width: auto; margin-left: auto; margin-right: auto;">...</div></syntaxhighlight>
 
== See also ==
* {{Tl|Float}}




<includeonly>[[Category:Formatting templates]]</includeonly>
<includeonly><!-- Categories below this line; interwikis at Wikidata -->
[[Category:Formatting templates]]</includeonly>

Latest revision as of 06:28, 1 May 2021


Description

This template's purpose is to center any elements supplied to it on the page, regardless of the browser used and the width of the display or window. This is done by wrapping the contents in </div><div> HTML5 tags that have the following CSS 3.0 properties:
width: auto; margin-left: auto; margin-right: auto;

Usage

Simply place any valid Wikitext you wish to appear centered as the contents of the (only) unnamed parameter, as in...

{{Center|Elements (text, images, etc.) to be centered here}}

...which is rendered by the parser as:

Elements (text, images, etc.) to be centered here

Additional CSS properties

This template does have one named parameter, style, which can be used to pass additional CSS properties to the wrapping <div> tags. The properties should be well-formed CSS 3.0, with colon-delimited property names and all values terminated with a semicolon. As an example, if it was desired to have the template's output be double-spaced below the preceding text and in a larger, bold font, it would look like...

{{Center|style=margin-top: 2em; font-size: larger; font-weight: bold;|Elements (text, images, etc.) to be centered here}}

...which is rendered as:

Elements (text, images, etc.) to be centered here

Bare HTML tags

To do this without a template, simply use the following HTML code, replacing the '...' with any standard Wikitext you want to appear centered on the page (multiple lines are acceptable, too):

<div class="center" style="width: auto; margin-left: auto; margin-right: auto;">...</div>

See also