Difference between revisions of "Template:Center/doc"
From LIMSWiki
Jump to navigationJump to searchShawndouglas (talk | contribs)  (Created.)  | 
				Shawndouglas (talk | contribs)   (Updated as needed.)  | 
				||
| Line 1: | Line 1: | ||
{{Documentation subpage}}  | {{Documentation subpage}}  | ||
<!--PLEASE ADD CATEGORIES AT THE END OF THIS PAGE.--->  | |||
A simple template to center-align content in tables and other places.  | |||
<!  | == Example ==  | ||
{{markup  | |||
| <nowiki>{{Center|Hello world!}}</nowiki>  | |||
| {{Center|Hello world!}}  | |||
}}  | |||
To do this without a template, simply use the following code:  | |||
:{{tag|div|params=class="center" style="width:auto; margin-left:auto; margin-right:auto;"}}  | |||
===   | === Centering tables ===  | ||
<nowiki>{  | Centered tables can be achieved, but they don't "float"; that is to say no text appears to either side. The trick is <code><nowiki>{| style="margin: 1em auto 1em auto;"</nowiki></code>  | ||
Wiki markup:  | |||
<pre>  | |||
Text before table...  | |||
{| class="wikitable" style="margin: 1em auto 1em auto;"  | |||
|+ '''Cells left-aligned, table centered'''  | |||
! scope="col" | Duis  | |||
! scope="col" | aute  | |||
! scope="col" | irure  | |||
|-  | |||
| dolor  || in reprehenderit || in voluptate velit  | |||
|-  | |||
| esse cillum dolore || eu fugiat nulla || pariatur.  | |||
|}  | |||
...text after table  | |||
</pre>  | |||
As it appears in a browser:  | |||
:  | <div style="background: white; border: 2px solid rgb(0, 255, 0); padding: 2px;">  | ||
Text before table...  | |||
{| class="wikitable" style="margin: 1em auto 1em auto;"  | |||
|+ '''Cells left-aligned, table centered'''  | |||
! Duis || aute || irure  | |||
|-  | |||
| dolor  || in reprehenderit || in voluptate velit  | |||
|-  | |||
| esse cillum dolore || eu fugiat nulla || pariatur.  | |||
|}  | |||
...text after table  | |||
</div>  | |||
=== Table ===  | |||
{| class="wikitable"  | |||
!colspan="3" style="width:300px"| Header text  | |||
|-  | |||
| {{Left2|Left2}} || {{Center|Center}} || {{Right|Right}}  | |||
|}  | |||
== See also ==  | |||
*{{hlist|{{tl|Startcenter}}|{{tl|Endcenter}}}}  | |||
*{{tl|Left}}  | |||
*{{tl|Left2}}  | |||
*{{tl|Right}}  | |||
<includeonly><!--  | <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |  | ||
| <!---CATEGORIES BELOW THIS LINE, PLEASE:--->  | |||
[[Category:  | [[Category:LIMSWiki formatting and function templates]]  | ||
</includeonly>  | }}</includeonly>  | ||
Latest revision as of 23:16, 27 February 2015
| 
   | 
 This is a documentation subpage for Template:Center. It contains usage information, categories, interlanguage links, and other content that is not part of the original template page.  | 
A simple template to center-align content in tables and other places.
Example
| Markup | Renders as | 
|---|---|
{{Center|Hello world!}}
 | 
Hello world! 
 | 
To do this without a template, simply use the following code:
<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">...</div>
Centering tables
Centered tables can be achieved, but they don't "float"; that is to say no text appears to either side. The trick is {| style="margin: 1em auto 1em auto;"
Wiki markup:
Text before table...
{| class="wikitable" style="margin: 1em auto 1em auto;"
|+ '''Cells left-aligned, table centered'''
! scope="col" | Duis
! scope="col" | aute
! scope="col" | irure
|-
| dolor  || in reprehenderit || in voluptate velit
|-
| esse cillum dolore || eu fugiat nulla || pariatur.
|}
...text after table
As it appears in a browser:
Text before table...
| Duis | aute | irure | 
|---|---|---|
| dolor | in reprehenderit | in voluptate velit | 
| esse cillum dolore | eu fugiat nulla | pariatur. | 
...text after table
Table
| Header text | ||
|---|---|---|
Left2  | 
Center  | 
Right 
 | 
See also
- {{Startcenter}}
 - {{Endcenter}}
 
- {{Left}}
 - {{Left2}}
 - {{Right}}
 







