I'm Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with HTML, CSS and SVG. To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

my books

Pro CSS3 Animation, Apress, 2013

Using SVG with CSS3 and HTML5, O'Reilly, 2017

my other blogs

Massive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New Defaults — A Sass color keyword system for designers. Replaces CSS defaults with improved hues and more memorable, relevant color names.

CSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

CSS3 2D Transformations: Introduction

An introduction to CSS3 transforms

Making elements look "different" under certain conditions has always been possible in CSS, initiated by simple pseudo-classes like :hover. CSS3 Transforms simply extend this capability into movement and animation. This fresh ability in CSS runs up against traditional uses of JavaScript, and is beginning to supplement and replace it. With the growth of HTML5, CSS3 and related technologies, JavaScript is slowly being shifted back to where its use is most appropriate: in browser interaction and scripting, rather than for appearance or effects. For example, JavaScript should not be used to provide table rows with different background colours, but scripted instead to provide the ability sort the data in those rows.

Transformations are currently in draft with W3C, and therefore have vendor prefixes added to every property. The base transformations are rotate, skew, scale and translate, with a matrix property to allow all four transformations to be implemented at once. In many ways, scale and translate are just handy alternatives to manipulating the properties left, top, right, bottom, width and height, but skew and rotate are completely new.

Transformation is in most cases from the computed centre of an element. In order to change this, you must alter the transform-origin property.

CSS3 transformations are supported in Opera 10.5+, Safari 3+, Firefox 3.5+, and all versions of Chrome. I probably don't need to tell you at this stage that Internet Explorer versions 6 – 8 have no understanding of the properties, although the browser does have its own proprietary way of doing things. IE 9 supports the syntax I will show here.

To create a transformation, use the transform property and attach the transform you wish to use, with the appropriate values in parentheses.

There are also 3D CSS transforms, as well as animations (also known as transitions), which we will approach later.

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.