Jump to content

Template:Transform-rotate/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Edokter moved page Template:Rotate/doc to Template:Transform-rotate/doc: Proper CSS name / Avoid name clash with Commons template
No edit summary
Line 16: Line 16:
!Syntax!!Result
!Syntax!!Result
|-valign=top
|-valign=top
|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>
|width=50%|<code><nowiki>*Some rotated characters:<br /><span style="{{Transform-rotate|90}}">A</span> <span style="{{Transform-rotate|180}}">B</span> <span style="{{Transform-rotate|270}}">C</span> <span style="{{Transform-rotate|360}}">D</span></nowiki></code>
<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>
<code><nowiki>*Works with numbers, too:<br /><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></nowiki></code>


<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>
<code><nowiki>*Or with arbitrary text:<br /><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></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>
*Some rotated characters:<br /><span style="{{Transform-rotate|90}}">A</span> <span style="{{Transform-rotate|180}}">B</span> <span style="{{Transform-rotate|270}}">C</span> <span style="{{Transform-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>
*Works with numbers, too:<br /><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>
*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>
*Or with arbitrary text:<br /><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>
|-valign=top
|-valign=top
|<code><nowiki>This is a placeholder image:</nowiki></code>
|<code><nowiki>This is a placeholder image:</nowiki></code>


<code><nowiki><div style="position:relative; top:150px; left:-60px; {{rotate|90|display=block}}">[[file:placeholder.png|200px]]</div></nowiki></code>
<code><nowiki><div style="position:relative; top:150px; left:-60px; {{Transform-rotate|90|display=block}}">[[file:placeholder.png|200px]]</div></nowiki></code>


<code><nowiki>It is rotated 90 degree clockwise.</nowiki></code>
<code><nowiki>It is rotated 90 degree clockwise.</nowiki></code>
|This is a placeholder image:
|This is a placeholder image:


<div style="position:relative; top:150px; left:-60px; {{rotate|90|display=block}}">[[file:placeholder.png|200px]]</div>
<div style="position:relative; top:150px; left:-60px; {{Transform-rotate|90|display=block}}">[[file:placeholder.png|200px]]</div>


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



Revision as of 13:23, 8 January 2014

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

  • First unnamed Parameter {{{1}}} for rotation angle (in degree). Positive values rotate right, negative values rotate left.
  • Second named Parameter display= allows to change the CSS display property. It defaults to display: inline-block;

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

information 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 Lua.

Examples

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:<br /><span style="{{Transform-rotate|90}}">A</span> <span style="{{Transform-rotate|180}}">B</span> <span style="{{Transform-rotate|270}}">C</span> <span style="{{Transform-rotate|360}}">D</span>

*Works with numbers, too:<br /><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>

*Or with arbitrary text:<br /><span style="{{Transform-rotate|-90}}">This text<br />is vertically<br />aligned.</span><br /> <br /><span style="{{Transform-rotate|-180}}">This text is upside down.</span>

  • Some rotated characters:
    A B C D
  • Works with numbers, too:
    0 1 2 3 4 5 6 7 8 9
  • Or with arbitrary text:
    This text
    is vertically
    aligned.

     
    This text is upside down.
This is a placeholder image:

<div style="position:relative; top:150px; left:-60px; {{Transform-rotate|90|display=block}}">[[file:placeholder.png|200px]]</div>

It is rotated 90 degree clockwise.

This is a placeholder image:

It is rotated 90 degree clockwise.

<div style="border:3px solid red; width:100px; position:relative; top:30px; opacity:0.5; {{Transform-rotate|-30|display=block}}"/>This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.
This is a red horizontal line drawn across the text at the angle of 30 degree anticlockwise.

See also:

template:MirrorH