Jump to content

Template:Transform-rotate/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
mNo edit summary
TemplateData
 
(32 intermediate revisions by 18 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}{{tsh|rotate}}
<!-- Categories and interwikis go at the bottom of this page. -->
<!-- Categories and interwikis go at the bottom of this page. -->
A shorthanded [[Cascading style sheet|CSS]] code for rotating elements inside style attribute. Use it inside the <code>style=""</code> attribute of HTML elements like other CSS properties.
A shorthanded [[Cascading style sheet|CSS]] code for rotating elements inside style attribute. Use it inside the <code>style=""</code> attribute of HTML elements like other CSS properties.


When using this template to create the rotating effect, editors should carefully consider the [[WP:accessibility|accessibility]].
*First unnamed Parameter <code>{{{1}}}</code> for rotation angle (in degree). Positive values rotate right, negative values rotate left.
*Second named Parameter <code>display=</code> allows to change the CSS display property. It defaults to <code>display: inline-block;</code>

When using this template to create the rotating effect, editors should consider carefully about the [[WP:accessibility|accessibility]].

''{{A note}} This template does not support IE8 or older browsers. IE8 requires cumbersome calculating of matrices. You may implement it into this template if you know how to translate the formula into [[Wikipedia:Lua|Lua]].''


==Examples==
==Examples==
Line 15: Line 10:
{|class=wikitable
{|class=wikitable
!Syntax!!Result
!Syntax!!Result
|- style="vertical-align:top;"
|-valign=top
|colspan=2|
|width=50%|<code><nowiki>*Some rotated characters:<br /><span style="{{rotate|90}}">A</span> <span style="{{rotate|180}}">B</span> <span style="{{rotate|270}}">C</span> <span style="{{rotate|360}}">D</span></nowiki></code>
*'''Some rotated characters:'''
<code><nowiki>*Works with numbers, too:<br /><span style="{{rotate|0}}">0</span> <span style="{{rotate|10}}">1</span> <span style="{{rotate|20}}">2</span> <span style="{{rotate|30}}">3</span> <span style="{{rotate|40}}">4</span> <span style="{{rotate|50}}">5</span> <span style="{{rotate|60}}">6</span> <span style="{{rotate|70}}">7</span> <span style="{{rotate|80}}">8</span> <span style="{{rotate|90}}">9</span></nowiki></code>
|-
|<syntaxhighlight lang="html"><span style="{{Transform-rotate|90}}">5</span> <span style="{{Transform-rotate|180}}">5</span> <span style="{{Transform-rotate|270}}">5</span> <span style="{{Transform-rotate|360}}">5</span></syntaxhighlight>
|<span style="{{Transform-rotate|90}}">5</span> <span style="{{Transform-rotate|180}}">5</span> <span style="{{Transform-rotate|270}}">5</span> <span style="{{Transform-rotate|360}}">5</span>
|-
|colspan=2|
*'''Some rotated special characters ''(useful when the font-family has no italic or oblique font)'':'''
|-
|<syntaxhighlight lang="html"><span style="font-size: 1.4em; {{Transform-rotate|0}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|20}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|40}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|60}}">∫</span></syntaxhighlight>
|<span style="font-size: 1.4em; {{Transform-rotate|0}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|20}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|40}}">∫</span> <span style="font-size: 1.4em; {{Transform-rotate|60}}">∫</span>
|-
|colspan=2|
*'''Works with numbers, too'''
|-
|<syntaxhighlight lang="html"><span style="{{Transform-rotate|0}}">0</span> <span style="{{Transform-rotate|10}}">1</span> <span style="{{Transform-rotate|20}}">2</span> <span style="{{Transform-rotate|30}}">3</span> <span style="{{Transform-rotate|40}}">4</span> <span style="{{Transform-rotate|50}}">5</span> <span style="{{Transform-rotate|60}}">6</span> <span style="{{Transform-rotate|70}}">7</span> <span style="{{Transform-rotate|80}}">8</span> <span style="{{Transform-rotate|90}}">9</span></syntaxhighlight>
|<span style="{{Transform-rotate|0}}">0</span> <span style="{{Transform-rotate|10}}">1</span> <span style="{{Transform-rotate|20}}">2</span> <span style="{{Transform-rotate|30}}">3</span> <span style="{{Transform-rotate|40}}">4</span> <span style="{{Transform-rotate|50}}">5</span> <span style="{{Transform-rotate|60}}">6</span> <span style="{{Transform-rotate|70}}">7</span> <span style="{{Transform-rotate|80}}">8</span> <span style="{{Transform-rotate|90}}">9</span>
|-
|colspan=2|
*'''Or with arbitrary text'''
|-
|<syntaxhighlight lang="html"><span style="{{Transform-rotate|-90}}">This text<br />is vertically<br />aligned.</span><br />&nbsp;<br /><span style="{{Transform-rotate|-180}}">This text is upside down.</span></syntaxhighlight>
|<span style="{{Transform-rotate|-90}}">This text<br />is vertically<br />aligned.</span><br />&nbsp;<br /><span style="{{Transform-rotate|-180}}">This text is upside down.</span>
|-
|colspan=2|
*'''This is a placeholder image, It is rotated 90 degrees clockwise.'''
|-style="vertical-align:top;"
|<syntaxhighlight lang="html"><div style="position:relative; top:0px; left:0px; {{Transform-rotate|90|display=block}}">[[file:Image PlaceHolder.png|200px]]</div></syntaxhighlight>
|<div style="position:relative; top:0px; left:0px; {{Transform-rotate|90|display=block}}">[[file:Image PlaceHolder.png|200px]]</div>
|-
|colspan=2|
*'''This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.'''
|-style="vertical-align:top;"
|<syntaxhighlight lang="html"><div style="border:3px solid red; width:150px; position:relative; top:50px; opacity:0.5; {{Transform-rotate|-30|display=block}}"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</syntaxhighlight>
|<div style="border:3px solid red; width:150px; position:relative; top:50px; opacity:0.5; {{Transform-rotate|-30|display=block}}"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|}


Serious limitation:
<code><nowiki>*Or with arbitrary text:<br /><span style="{{rotate|-90}}">This text<br />is vertically<br />aligned.</span><br />&nbsp;<br /><span style="{{rotate|-180}}">This text is upside down.</span></nowiki></code>
|
*Some rotated characters:<br /><span style="{{rotate|90}}">A</span> <span style="{{rotate|180}}">B</span> <span style="{{rotate|270}}">C</span> <span style="{{rotate|360}}">D</span>
*Works with numbers, too:<br /><span style="{{rotate|0}}">0</span> <span style="{{rotate|10}}">1</span> <span style="{{rotate|20}}">2</span> <span style="{{rotate|30}}">3</span> <span style="{{rotate|40}}">4</span> <span style="{{rotate|50}}">5</span> <span style="{{rotate|60}}">6</span> <span style="{{rotate|70}}">7</span> <span style="{{rotate|80}}">8</span> <span style="{{rotate|90}}">9</span>
*Or with arbitrary text:<br /><span style="{{rotate|-90}}">This text<br />is vertically<br />aligned.</span><br />&nbsp;<br /><span style="{{rotate|-180}}">This text is upside down.</span>
|-valign=top
|<code><nowiki>This is a placeholder image:</nowiki></code>


{|class=wikitable
<code><nowiki><div style="position:relative; top:150px; left:-60px; {{rotate|90|display=block}}">[[file:placeholder.png|200px]]</div></nowiki></code>
!Syntax!!Result
|-
| <syntaxhighlight lang="html"><span style="{{Transform-rotate|90}}">The text will be rotated, but not the space the text need to display. So the cell is not tall enough, but much much too wide.</span></syntaxhighlight>
| <span style="{{Transform-rotate|90}}">The text will be rotated, but not the space the text need to display. So the cell is not tall enough, but much much too wide.</span>
|-
|}


==TemplateData==
<code><nowiki>It is rotated 90 degree clockwise.</nowiki></code>
{{TemplateData header}}
|This is a placeholder image:


<templatedata>
<div style="position:relative; top:150px; left:-60px; {{rotate|90|display=block}}">[[file:placeholder.png|200px]]</div>
{
"params": {
"1": {
"label": "Rotation angle",
"description": "Positive degrees rotate right, negative values rotate left",
"type": "number",
"default": "0"
},
"display": {
"label": "CSS display",
"type": "string",
"default": "inline-block"
}
}
}</templatedata>


==See also:==
It is rotated 90 degree clockwise.
* {{tl|Rotate text}}
|-valign=top
* {{tl|MirrorH}}
|<code><nowiki><div style="border:3px solid red; width:100px; position:relative; top:30px; opacity:0.5; {{rotate|-30|display=block}}"/>This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.</nowiki></code>
|<div style="border:3px solid red; width:100px; position:relative; top:30px; opacity:0.5; {{rotate|-30|display=block}}"/>This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.
|}


<includeonly>
<includeonly>{{Sandbox other||
<!-- Categories and interwikis go here: -->
<!-- Categories and interwikis go here: -->
[[Category:Graphics templates]]
[[Category:Cross-browser compatibility templates]]
[[Category:Cross-browser compatibility templates]]
}}</includeonly>
[[Category:Graphic templates]]

[[ru:Шаблон:Rotate]]
[[zh:Template:Rotate]]
</includeonly>

Latest revision as of 00:34, 9 July 2024

A shorthanded CSS code for rotating elements inside style attribute. Use it inside the style="" attribute of HTML elements like other CSS properties.

When using this template to create the rotating effect, editors should carefully consider the accessibility.

Examples

[edit]

The rotating happens at the center of the object and its effective dimensions will retain the original values of the object as if unrotated, so you may adjust the position and padding to avoid unwanted overlapping. Use the display= parameter to further control positioning.

Syntax Result
  • Some rotated characters:
<span style="{{Transform-rotate|90}}">5</span> <span style="{{Transform-rotate|180}}">5</span> <span style="{{Transform-rotate|270}}">5</span> <span style="{{Transform-rotate|360}}">5</span>
5 5 5 5
  • Some rotated special characters (useful when the font-family has no italic or oblique font):
<span style="font-size: 1.4em; {{Transform-rotate|0}}"></span> <span style="font-size: 1.4em; {{Transform-rotate|20}}"></span> <span style="font-size: 1.4em; {{Transform-rotate|40}}"></span> <span style="font-size: 1.4em; {{Transform-rotate|60}}"></span>
  • Works with numbers, too
<span style="{{Transform-rotate|0}}">0</span> <span style="{{Transform-rotate|10}}">1</span> <span style="{{Transform-rotate|20}}">2</span> <span style="{{Transform-rotate|30}}">3</span> <span style="{{Transform-rotate|40}}">4</span> <span style="{{Transform-rotate|50}}">5</span> <span style="{{Transform-rotate|60}}">6</span> <span style="{{Transform-rotate|70}}">7</span> <span style="{{Transform-rotate|80}}">8</span> <span style="{{Transform-rotate|90}}">9</span>
0 1 2 3 4 5 6 7 8 9
  • Or with arbitrary text
<span style="{{Transform-rotate|-90}}">This text<br />is vertically<br />aligned.</span><br />&nbsp;<br /><span style="{{Transform-rotate|-180}}">This text is upside down.</span>
This text
is vertically
aligned.

 
This text is upside down.
  • This is a placeholder image, It is rotated 90 degrees clockwise.
<div style="position:relative; top:0px; left:0px; {{Transform-rotate|90|display=block}}">[[file:Image PlaceHolder.png|200px]]</div>
  • This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.
<div style="border:3px solid red; width:150px; position:relative; top:50px; opacity:0.5; {{Transform-rotate|-30|display=block}}"></div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Serious limitation:

Syntax Result
<span style="{{Transform-rotate|90}}">The text will be rotated, but not the space the text need to display. So the cell is not tall enough, but much much too wide.</span>
The text will be rotated, but not the space the text need to display. So the cell is not tall enough, but much much too wide.

TemplateData

[edit]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Transform-rotate in articles based on its TemplateData.

TemplateData for Transform-rotate

No description.

Template parameters

ParameterDescriptionTypeStatus
Rotation angle1

Positive degrees rotate right, negative values rotate left

Default
0
Numberoptional
CSS displaydisplay

no description

Default
inline-block
Stringoptional

See also:

[edit]