Vorlage:Nowrap: Unterschied zwischen den Versionen

Aus Nerds Go Wiki
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „{{Documentation subpage}} <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> {{Uses TemplateStyles|Template:Nowrap/s…“)
 
(Der Seiteninhalt wurde durch einen anderen Text ersetzt: „<onlyinclude><templatestyles src="Template:Nowrap/styles.css"/><span class="nowrap">{{{1}}}</span></onlyinclude> {{Documentation}} <…“)
Markierung: Ersetzt
 
Zeile 1: Zeile 1:
{{Documentation subpage}}
+
<onlyinclude><templatestyles src="Template:Nowrap/styles.css"/><span class="nowrap">{{{1}}}</span></onlyinclude>
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
+
{{Documentation}}
{{Uses TemplateStyles|Template:Nowrap/styles.css}}
+
<!-- Add categories to the /doc subpage and interwikis in Wikidata, not here! -->
 
 
{{tlx|Nowrap}} or {{tlx|nowrap}} stops wrapping of specific text. It prevents word wraps (line breaks) within text or inside a link which contains spaces, hyphens&nbsp;("-"), or, in some browsers, parentheses. The size of the nowrapped text becomes the minimum width of that paragraph and that can negatively influence the ability of the page to adapt to smaller screens, or alternate representations of the content.
 
 
 
== Usage ==
 
:: <code><nowiki>{{Nowrap|these words stay together}}</nowiki></code>
 
:: <code><nowiki>{{Nowrap|a, b, c, or d.}}</nowiki></code>
 
:: <code><nowiki>{{Nowrap| merry-go-round }}</nowiki></code>
 
:: <code><nowiki>{{Nowrap| [[4-part harmony]] }}</nowiki></code>
 
:: <code><nowiki>{{Nowrap| [[Cascading Style Sheets|CSS]] }}</nowiki></code>
 
:: <code><nowiki>{{Nowrap| [[#Examples|Examples section]] }}</nowiki></code>
 
 
 
=== Examples ===
 
{| class=wikitable
 
|"<code>They held <nowiki>{{Nowrap|10 kg (22 lb)}}</nowiki> in total.</code>"
 
<br/> May render like this:
 
:They held {{Nowrap|10 kg (22 lb)}} <br/>in total.
 
<br/> Or like this:
 
:They held <br/>10 kg (22 lb) in total.
 
<br/> But ''not'' render like this:
 
:They held 10 kg (22 <br/>lb) in total.
 
 
 
| "<code>He encountered <nowiki>{{Nowrap|a tiger}}</nowiki> in the woods.</code>"
 
<br/> May render like this:
 
:He encountered a tiger <br/>in the woods.
 
<br/> Or like this:
 
:He encountered <br/>a tiger in the woods.
 
<br/> But ''not'' like this:
 
:He encountered a <br/>tiger in the woods.
 
|}
 
 
 
=== Handling equal-sign or bar ===
 
[[Help:Templates|Templates]] have problems with parameter data that contains equal-signs "<code>=</code>" or vertical bars "<code>|</code>" (pipes). Note that this does not apply if the equal-sign "<code>=</code>" or vertical bar "<code>|</code>" is inside a wikilink or another template. However, there are workarounds:
 
 
 
For text that includes an equal-sign "=", precede the text with <code>1=</code>, use a triple-brace unnamed parameter <code><nowiki>{{{|=}}}</nowiki></code>, or the <code><nowiki>{{=}}</nowiki></code> template. For example:
 
:<code><nowiki>{{Nowrap|</nowiki>1=2 + 2 = 4}}</code>, <br /><code><nowiki>{{Nowrap|2 + 2 {{{|=}}} 4}}</nowiki></code>, or <br /><code><nowiki>{{Nowrap|2 + 2 {{=}} 4}}</nowiki></code>
 
 
 
which all render as this:
 
:{{Nowrap|1=2 + 2 = 4}}.
 
 
 
For text that includes a vertical bar "|", escape the bar(s) with "<code><nowiki>&amp;#124;</nowiki></code>" or "<code><nowiki>{{!}}</nowiki></code>". For instance, put two bars "|6|" like this:
 
:<code><nowiki>{{Nowrap|</nowiki>&amp;#124;6&amp;#124; < 7}}</code> &nbsp;or&nbsp; <code><nowiki>{{Nowrap|{{!}}6{{!}} < 7}}</nowiki></code>
 
 
 
Which renders this:
 
:{{Nowrap|&#124;6&#124; < 7}}
 
 
 
== Technical details ==
 
 
 
The actual code that does the job is this HTML {{tag|span|open|link=yes}} tag that applies a class to the text inside the template:
 
 
 
<syntaxhighlight lang="html">
 
<span class="nowrap">This text will not wrap</span>
 
</syntaxhighlight>
 
 
 
The class <code>nowrap</code> receives the CSS property <syntaxhighlight lang="css" inline>white-space: nowrap;</syntaxhighlight> in {{Blue|MediaWiki:Common.css}}.
 
 
 
== TemplateData ==
 
{{TemplateData header}}
 
<templatedata>
 
{
 
"description": {
 
"en": "Prevents word wraps (line breaks) within text or inside a link which contains spaces or hyphens (-)."
 
},
 
"format": "inline",
 
"params": {
 
"1": {
 
"label": {
 
"en": "Text"
 
},
 
"description": {
 
"en": "Text or link to be protected."
 
},
 
"type": "string",
 
"required": true
 
}
 
}
 
}
 
</templatedata>
 
<includeonly>{{Sandbox other||
 
<!-- Categories below this line; interwikis at Wikidata -->
 
[[Category:Formatting templates]]
 
}}</includeonly>
 

Aktuelle Version vom 11. Oktober 2022, 12:59 Uhr

<templatestyles src="Template:Nowrap/styles.css"/>{{{1}}} Vorlage:Documentation