Template:Resize/doc: Difference between revisions

From HIBIKIFORUM
Jump to navigation Jump to search
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{template rating|p}}
__NOTOC__


==Usage==
It is to change the font size of a text string.
<code><nowiki>{{resize|N|text}}</nowiki></code> — N specifies a size, such as "95%", "1.2em", etc.


<code><nowiki>{{resize|text}}</nowiki></code> — If N is omitted, as in the second line above, a default 90% size is applied.
== Syntax ==
* {{tlc|Resize|''N''|text}} — ''N'' specifies a size, such as "95%", "1.2em", etc.
* {{tlc|Resize|''text''}} — If ''N'' is omitted, as in the second line above, a default 90% size is applied.
* {{tlc|resize|div{{=}}yes|''text''}} — As above but uses a div tag instead of a span tag.


==Beware==
== Beware ==
{{font color|red|Beware}} that if <code>text</code> happens to contain an equality sign (=), it will fail to render properly. Here are the workarounds:
{{font color|red|Beware}} that if {{code|text}} happens to contain an equality sign (=), it will fail to render properly. Here are the workarounds:


<ol>
# Replace all instances of {{code|=}} with {{tl|{{=}}}}, or
<li>Replace all instances of <code>=</code> with <code><nowiki>{{=}}</nowiki></code>, or </li>
# Specify {{tlc|resize|N|2{{=}}text}} or {{tlc|resize|1{{=}}text}}.
<li>Specify <code><nowiki>{{resize|N|2=text}}</nowiki></code> or <code><nowiki>{{resize|1=text}}</nowiki></code>.</li>
</ol>


Also it will fail to wrap multiple blocks, such as multiple paragraphs or multiple bullet points. Here are the workarounds:
 
<ol>
Also it will fail to wrap multiple blocks, such as multiple paragraphs or multiple bullet points. Here are the workarounds:  
<li>Use, for example,<br />
# Use, for example, <br/><code>&lt;div style="font-size:90%;"></code><br/>...''multiple paragraphs''...<br/><code>&lt;/div></code>, or
<code><nowiki><div style="font-size:90%;"></nowiki></code><br />
# Apply this template separately to each block of paragraph, bullet point etc.
...multiple paragraphs...<br />
# Use {{tlf|resize|2=div=yes}}.
<code><nowiki></div></nowiki></code>, or </li>
 
<li>Apply this template separately to each block of paragraph, bullet point etc.</li>
== Examples ==
</ol>
{| class="wikitable"
|-
! Code !! Result
|-
| {{tlc|resize|This text defaults to 90% normal size.}} || {{resize|This text defaults to 90% normal size.}}
|-
| {{tlc|resize|80%|This text is 80% normal size.}} || {{resize|80%|This text is 80% normal size.}}
|-
| {{tlc|resize|1.2em|This text is 0.2em larger than normal.}} || {{resize|1.2em|This text is 0.2em larger than normal.}}
|-
| {{tlc|resize|We know 1+1{{=}}2 and 2+2{{=}}4. It will fail to render}} || {{resize|We know 1+1=2 and 2+2=4. It will fail to render}}
|-
| {{tlc|resize|We know 1+1<nowiki>{{=}}</nowiki>2 and 2+2<nowiki>{{=}}</nowiki>4.}} || {{resize|We know 1+1{{=}}2 and 2+2{{=}}4.}}
|-
| {{tlc|resize|1{{=}}We know 1+1{{=}}2 and 2+2{{=}}4.}} || {{resize|1=We know 1+1=2 and 2+2=4.}}
|-
| {{tlc|resize|120%|2{{=}}We know 1+1{{=}}2 and 2+2{{=}}4. This text is 120% normal size.}} || {{resize|120%|2=We know 1+1=2 and 2+2=4. This text is 120% normal size.}}
|}
 
== TemplateData ==
<templatedata>{
  "description": "It is to change the font size of a text string. Two forms {{resize|<size>|<text>}} and {{resize|<text>}} are possible.",
  "params": {
    "1": {
      "label": "Size/Text",
      "description": "Specifies a css font size e.g. '80%', '1.2em', 'x-large', 'larger'. In the one parameter version the first parameter is the text and the font size is '90%'.",
      "type": "string",
      "required": true
    },
    "2": {
      "label": "Text when size is given",
      "description": "The text to display in the two parameter version.",
      "type": "string",
      "required": false
    },
    "div": {
      "label": "Use div tag",
      "description": "Set to yes to use a div instead of a span tag.",
      "type": "string",
      "required": false
    }
  }
}
</templatedata>
 
<includeonly>{{sandbox other||{{testcases other||
 
<!-- Categories below this line, please -->
[[Category:General use templates]]
}}}}</includeonly>

Latest revision as of 02:36, 20 August 2023

Light bulb.png }}
It contains usage information, categories and other content that is not part of the original template page.


It is to change the font size of a text string.

Syntax

  • {{Resize|N|text}}N specifies a size, such as "95%", "1.2em", etc.
  • {{Resize|text}} — If N is omitted, as in the second line above, a default 90% size is applied.
  • {{resize|div=yes|text}} — As above but uses a div tag instead of a span tag.

Beware

Beware that if text happens to contain an equality sign (=), it will fail to render properly. Here are the workarounds:

  1. Replace all instances of {{{1}}} with {{=}}, or
  2. Specify {{resize|N|2=text}} or {{resize|1=text}}.


Also it will fail to wrap multiple blocks, such as multiple paragraphs or multiple bullet points. Here are the workarounds:

  1. Use, for example,
    <div style="font-size:90%;">
    ...multiple paragraphs...
    </div>, or
  2. Apply this template separately to each block of paragraph, bullet point etc.
  3. Use {{resize|div=yes}}.

Examples

Code Result
{{resize|This text defaults to 90% normal size.}} This text defaults to 90% normal size.
{{resize|80%|This text is 80% normal size.}} This text is 80% normal size.
{{resize|1.2em|This text is 0.2em larger than normal.}} This text is 0.2em larger than normal.
{{resize|We know 1+1=2 and 2+2=4. It will fail to render}} {{{1}}}
{{resize|We know 1+1{{=}}2 and 2+2{{=}}4.}} We know 1+1=2 and 2+2=4.
{{resize|1=We know 1+1=2 and 2+2=4.}} We know 1+1=2 and 2+2=4.
{{resize|120%|2=We know 1+1=2 and 2+2=4. This text is 120% normal size.}} We know 1+1=2 and 2+2=4. This text is 120% normal size.

TemplateData

It is to change the font size of a text string. Two forms {{resize|<size>|<text>}} and {{resize|<text>}} are possible.

Template parameters

ParameterDescriptionTypeStatus
Size/Text1

Specifies a css font size e.g. '80%', '1.2em', 'x-large', 'larger'. In the one parameter version the first parameter is the text and the font size is '90%'.

Stringrequired
Text when size is given2

The text to display in the two parameter version.

Stringoptional
Use div tagdiv

Set to yes to use a div instead of a span tag.

Stringoptional