×

css · level 3 · unit 5 · lesson 3

  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

sets the a box turns around.

Every turn and resize happens around a pivot, the fixed point that stays still. By default it is the centre of the box. transform-origin moves it.

Use keywords like top left or bottom, or lengths like 0 100%. A door swings from its hinge: transform-origin: left with rotate: -30deg. A dropdown grows from its top edge: transform-origin: top.

Percentages work too, measured from the top left corner: transform-origin: 50% 100% is the middle of the bottom edge.

<div class="door">Door</div>
.door {
  width: 80px;
  height: 120px;
  transform-origin: left;
  rotate: -30deg;
  color: white;
  background-color: #9a3412;
}

Press show my page to see it here.