# Animatable: Transform

## Brandon Rozek

October 18, 2015

This is the last post of the animatable series. The grand finale. Here, we will talk about the transform property. It’s only one property but it comes with a lot of goodies in the form of transform-functions.

This is not a comprehensize list. If you want one of those, please check out MDN. They have a great resource. This is the last post of the animatable series, I recommend you check out the other parts too.

Animatable: Transform goes with a CodePen demo{.broken_link} I made. Please check it out, as I will be referencing it later on in the post.

### rotate()

The rotate() function moves the element around a fixed point as defined by the transform-origin property. In the Codepen demo (#1), the star continously rotates 360 degrees.

@keyframes rotate {

to { transform: rotate(360deg);}

}

.rotate {

width: 6rem;

height: 6rem;

background-size: cover;

transform: none;

animation: rotate 1s ease 0s infinite;
}


### scale()

Scale(sx, sy) modifies the size of the element by taking 2 arguments: sx and sy. Where sx is the multiplier that scales the element in the x-direction while sy is the multiplier that scales the element in the y-direction. In the CodePen demo (#2), the little ninja man scales to half his size and back to normal again.

@keyframes scale {

to { transform: scale(.5); }

}

.scale {

width: 6rem;

height: 6rem;

background-size: contain;

background-repeat: no-repeat;

transform: none;

animation: scale 1s ease 0s infinite alternate;
}


### skew()

Skew distorts the element by moving each point to a certain angle determined by it’s distance from the origin. In the CodePen demo (#3), the square skews -20 degrees, making it appear as a parallelogram.

@keyframes skew {

to { transform: skew(-20deg); }

}

.skew {

height: 6rem;

width: 6rem;

background-color: lightblue;

transform: none;

animation: skew .75s ease 0s infinite alternate;
}


### translate()

Transform(tx, ty) moves the element as specified by it’s two parameters tx and ty. Tx tells the browser how many units to move it in the x direction while ty tells the browser how many units to move the element in the y direction. In the CodePen demo (#4), the car moves forward 10rem and back again.

@keyframes translate {

to { transform: translate(10rem);}

}

.translate {

height: 6rem;

width: 6rem;

background-image: url("http://res.freestockphotos.biz/pictures/15/15685-illustration-of-a-red-cartoon-car-pv.png");

background-size: contain;

background-repeat: no-repeat;

transform: none;

animation: translate 1s ease 0s infinite alternate;
}


### Conclusion

It is now the end of the Animatable series. I am sad to see this first completed series of mine go. It’s okay though, I’m bound to think of another series to write for you guys in no time. My goal in Animatable, is to show you (and me) what is possible using CSS animations. With this small reference completed, we have a good overview of the different tools available. Now with our new toolbelt, go out and craft meaningful experinces!