https://www.w3.org/wiki/api.php?action=feedcontributions&feedformat=atom&user=AfutekovW3C Wiki - User contributions [en]2024-03-19T02:30:37ZUser contributionsMediaWiki 1.41.0https://www.w3.org/wiki/index.php?title=CSS3_2D_Transforms&diff=57849CSS3 2D Transforms2012-04-12T00:59:04Z<p>Afutekov: </p>
<hr />
<div>== Introduction ==<br />
CSS3 allows us to manipulate objects in 2D space by the use of the <code>tranform</code> property and its functions for 2D transformations.<br />
<br />
== Transform Functions ==<br />
The <code>tranform</code> property specifies certain transformations to be applied to an element. It can combine several transform functions by separating them with whitespace, for example:<br />
<pre>transform: scale(2) rotate(180deg) translateX(15px);</pre><br />
<br />
<br />
=== Translate ===<br />
The <code>translate</code> function moves the element by an offset defined with two values, if only one value is defined, the second one is taken to be zero. Here is a basic example:<br />
<pre>transform: translate(30px, 20%);</pre><br />
<br />
If an object needs to be translated only on one axis the functions <code>translateX</code> and <code>translateY</code> can be used, they can represent the example above like this:<br />
<pre>transform: translateX(30px) translateY(20%);</pre><br />
Which would create an identical result.<br />
<br />
=== Scale ===<br />
The <code>scale</code> function resizes the entire element when using one or two unitless numbers, where <code>scale(1)</code> is no change, <code>scale(0.5)</code> is half the lenght and width, and <code>scale(2)</code> is twice the lenght and width. If two numbers are provided the first defines how much the element will be stretched/collapsed horizontally, and the second - vertically. The following example:<br />
<pre>transform: scale(3, 0.5);</pre><br />
Will stretch the object to three times its original width and will make it half as wide. This would be the same as declaring:<br />
<pre>transform: scaleX(3) scaleY(0.5);</pre><br />
<br />
=== Skew ===<br />
The <code>skew</code> function tilts the element by using one or two angle values. If <code>skewX(45deg)</code> is defined the top and bottom edges of the element will remain horizontal, but the left and right edges will be "leaning" to the <em>left</em> by 45 degrees. If <code>skewY(30deg)</code> is defined then the left and right edges of the element will remain vertical, but the top and bottom edges will be tilted to the <em>right</em> by 30 degrees.<br />
<br />
=== Rotate ===<br />
The <code>rotate</code> function rotates the element clockwise by an angle defined with a single value, for example:<br />
<pre>transform: rotate(45deg);</pre><br />
Will rotate the entire element by 45 degrees clockwise.<br />
<br />
<br />
== Transform Origin ==<br />
The transform-origin property sets the origin of a transformation (rotation, scale, etc.) of an object in a simple coordinate system. The default origin of each object is its geometric center.<br />
<br />
Setting two values for <code>transform-origin</code> defines the horizontal and vertical position.<br />
<br />
<code>transform-origin:</code> <code><percentage></code> or <code><length></code> or <code>left</code>/<code>center</code>/<code>right</code> <code>,</code> <code><percentage></code> or <code><length></code> or <code>top</code>/<code>center</code>/<code>bottom</code> <code>;</code><br />
<br />
If only one value is specified it refers to the horizontal position, the vertical position in this case is assumed to be 'center'.<br />
The <percentage> and <length> values here are the offset of the transform origin from the <em>top left</em> corner of the element.<br />
<br />
The <code>transform-origin</code> property can also receive more than two values:<br />
<pre>transform-origin: bottom 25px right 40%</pre><br />
<br />
In such cases, the second and the fourth values determines the offset from the edge defined by the keyword preceding it. The transform origin for the example above is 25px from the bottom and 40% from the right edge of the element.<br />
<br />
If only three values are given, the fourth missing value - the vertical offset - is assumed to be zero.<br />
<br />
== Summary ==<br />
The <code>scale</code>, <code>skew</code>, and <code>translate</code> functions can be used to declare its horizontal and vertical values both together or separately by using <code>scaleX</code>, <code>scaleY</code>, <code>skewX</code>, <code>skewY</code>, <code>translateX</code>, and <code>translateY</code>. The function <code>rotate</code> can have only one value.<br />
<br />
== Browser Support ==<br />
CSS transforms are currently supported with prefixes by these browsers:<br />
<br />
Chrome 10+<br />
<br />
Firefox 3.6+<br />
<br />
Internet Explorer 9+<br />
<br />
Opera 11+<br />
<br />
Safari 5+<br />
<br />
When declaring transforms always write the prefixed declarations first and the non-prefixed standard declaration at the end:<br />
<pre>-webkit-transform: <transform functions>;<br />
-moz-transform: <transform functions>;<br />
-ms-transform: <transform functions>;<br />
-o-transform: <transform functions>;<br />
transform: <transform functions>;</pre></div>Afutekovhttps://www.w3.org/wiki/index.php?title=CSS3_2D_Transforms&diff=57509CSS3 2D Transforms2012-03-29T21:27:27Z<p>Afutekov: Created page with "== Introduction == == Transform Functions == == Transform Origin == == Summary =="</p>
<hr />
<div>== Introduction ==<br />
<br />
== Transform Functions ==<br />
<br />
== Transform Origin ==<br />
<br />
== Summary ==</div>Afutekov