CSS3 transforms allow the rendering of an HTML element to be modified using 2D and 3D transformations such as rotation, scaling, and translations. Transforms are applied by setting the
-webkit-transform
CSS property with the desired list of transforms. Each transform takes the form of a transformation function, such as translate3d
or rotate
, and a list of parameters enclosed in brackets. For example, to move an object to the right by 100 pixels and rotate it by 45 degrees you can use the -webkit-transform
property: -webkit-transform: translate(100px, 0) rotate(45deg);
Using
-webkit-transform
as the transition property when moving an element is advantageous relative to using the standard top
and left
properties because transitions using -webkit-transform
are hardware-accelerated in Safari. An exception here is that it seems that 2D translations are not hardware-accelerated. But, since any 2D translation is equivalent to a corresponding 3D translation with the same translations in the x and y and no translation in the z axis, it is easy to use a hardware accelerated translate3d(x, y, 0) transform instead of a non-hardware accelerated translate(x, y)
transform.