Difference between revisions of "Template:Inline block/doc"

From blackwiki
Jump to navigation Jump to search
imported>GKFX
(Add centralized see also)
imported>GKFX
(→‎Usage: Adjust usage information)
Line 2: Line 2:
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
== Usage ==
 
== Usage ==
The template {{tlf|Inline block}} is intended to be used in place of {{tl|nowrap}} when coding templates with complex layout, which need to display differently on mobile and desktop. Like {{tlf|nowrap}}, it holds content together and avoids wrapping it where possible. However, if necessary, such as on small screens, the content will wrap.
+
The template {{tlf|Inline block}} creates an element—by default a {{tag|span|o}}—that has the [[CSS]] property <code>display: inline-block;</code>. There is support for a range of common style properties as template parameters, and an all-purpose <code>style</code> parameter.
  
===Example===
+
One intended use is to replace {{tl|nowrap}} when coding templates with complex layout, which need to display differently on mobile and desktop. Like {{tlf|nowrap}}, it holds content together and avoids wrapping it where possible. However, if necessary, such as on small screens, the content will wrap.
 +
 
 +
===Example of wrapping control===
 
In each case the outline represents a width constraint, which might be affected by the user's screen size, other parts of the template, or both.
 
In each case the outline represents a width constraint, which might be affected by the user's screen size, other parts of the template, or both.
  
Line 79: Line 81:
 
"background": {
 
"background": {
 
"label": "Background formatting",
 
"label": "Background formatting",
 +
            "aliases": ["bg"],
 
"description": "The background formatting; passed directly to the \"background\" CSS attribute",
 
"description": "The background formatting; passed directly to the \"background\" CSS attribute",
 
"type": "string"
 
"type": "string"
Line 88: Line 91:
 
}
 
}
 
},
 
},
"description": "The template &#123;&#123;Inline block&#125;&#125; is intended to be used in place of {{tl|nowrap}} when coding templates with complex layout."
+
"description": "The template &#123;&#123;Inline block&#125;&#125; creates an inline-block element. Among other uses, it can replace {{tl|nowrap}} when coding templates with complex layout."
 
} }}
 
} }}
  

Revision as of 13:35, 11 April 2018

Usage

The template {{Inline block}} creates an element—by default a <span>—that has the CSS property display: inline-block;. There is support for a range of common style properties as template parameters, and an all-purpose style parameter.

One intended use is to replace {{nowrap}} when coding templates with complex layout, which need to display differently on mobile and desktop. Like {{nowrap}}, it holds content together and avoids wrapping it where possible. However, if necessary, such as on small screens, the content will wrap.

Example of wrapping control

In each case the outline represents a width constraint, which might be affected by the user's screen size, other parts of the template, or both.

1 (red)=Gas3 (black)=Solid80 (green)=LiquidColor of the atomic number shows state of matter (at 0 °C and 1 atm)
1 (red)=Gas3 (black)=Solid80 (green)=LiquidColor of the atomic number shows state of matter (at 0 °C and 1 atm)
1 (red)=Gas3 (black)=Solid80 (green)=LiquidColor of the atomic number shows state of matter (at 0 °C and 1 atm)

Here, each grey box and the text "Color of ..." are wrapped in {{inline block}} templates. If {{nowrap}} had been used instead, there would be no visible difference in the first two cases. In the third case, however, the text would have been unable to wrap into the space available. On mobile, this might mean that a table or the whole article is forced to become horizontally scrollable.

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Inline block

The template {{Inline block}} creates an inline-block element. Among other uses, it can replace {{nowrap}} when coding templates with complex layout.
ParameterDescriptionTypeStatus
Content1
The content to be wrapped in an inline-block element
Contentrequired
Tag name2
Changes the HTML tag used. This may affect what elements this template should contain or be contained by.
Default
A span.
Example
div
Stringoptional
Widthwidth
The width; passed directly to the "width" CSS attribute
Stringoptional
Heightheight
The height; passed directly to the "height" CSS attribute
Stringoptional
Text colorcolor
The text color; passed directly to the "color" CSS attribute
Stringoptional
Background formattingbackground
bg
The background formatting; passed directly to the "background" CSS attribute
Stringoptional
Other stylesstyle
Style information as plain CSS.
Stringoptional

See also

  • {{nowrap}} prevents wrapping within a single template (i.e. not suitable for relatively complex or lengthy content).
  • {{nowraplinks}} ... {{nowraplinks end}} prevents wraps inside links while allowing wraps between links and in normal text. Very useful for link lists and easy to use.
  • {{nowrap begin}} ... {{nowrap end}} prevents wraps in both text and links. For the trickier wrapping cases when you need full control, for instance in very complex link lists.
  • {{avoid wrap}} prevents wraps unless the space is too narrow to display the text on one line.
    • {{inline block}} does the same and allows further style customization, but does not automatically add the "avoidwrap" CSS class.
  • {{spaces}} produces multiple non-breaking spaces (or a single one).
  • {{wrap}} can be used to provide a (brief) exception within a no-wrapping area.
    • {{normalwraplink}} allows links to wrap when they otherwise would not.
  • {{·}} and {{•}}, spaced and wrap-sensitive interpunct (dot) and bullet.
  • Help:Line-break handling, Wikipedia's how-to guide about word wrapping and line breaks.
    • In particular, to avoid line wrapping when quoting a passage such as a poem or computer code, see Script error: No such module "Section link".Template:Snde.g. Template:Blockquote with "poem" tag.