×

css · level 3 · unit 5 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

One transform can chain steps, and the order matters.

The older transform property takes a list of transform functions, each a step with brackets: transform: translate(40px, 0) rotate(45deg);. You will meet it everywhere, in libraries, tutorials and older code.

Order matters, because each step changes the directions the next step uses. Move then turn, and the box moves, then turns where it lands. Turn then move, and it moves along its new, turned direction.

The separate properties always run in one fixed order: translate, then rotate, then scale. Use transform when you need a different order.

<div class="tile">A</div>
.tile {
  width: 60px;
  height: 60px;
  transform: translate(40px, 0) rotate(45deg);
  background-color: #e0f2f1;
}

Press show my page to see it here.

Swap the two functions around and run it again to see the tile land somewhere else.