liveBook · Manning

Rotation

As explained in CSS in Depth, Second Edition

A rotation is a geometric transformation that turns an object around a fixed point or axis.

Rotation turns an element around an axis by a specified angle. In CSS, rotate() applies the change without altering the element’s place in document flow, so neighboring content can remain fixed or overlap. section 16.1 section 16.4

Use rotation by choosing an angle and then checking how the transformed element interacts with its surroundings.

  • Use positive angles for clockwise rotation and negative angles for rotation in the opposite direction, such as rotate(-30deg). section 16.1
  • Express angles with directions such as to right, degrees such as 90deg, radians, turns, or gradians; 0deg points up and 90deg points right. section 13.1
  • Treat rotate() as rotation around the z-axis; use rotateX() or rotateY() for three-dimensional pitching or yawing. section 16.4
  • Remember that rotation changes the rendered appearance but not normal document flow, which can produce overlap with other elements. section 16.1

Tilt a card

A card can be rotated with a single declaration: .card { transform: rotate(15deg); }. To move the already-rotated card horizontally, use transform: translate(50px, 0) rotate(15deg); transforms are applied from right to left, so the card rotates first and then translates. section 16.1 section 16.1.2

Listing 16.3 Applying multiple transforms
.card {
  max-inline-size: 300px;
  padding: 0.5em;
  margin-inline: auto;
  background-color: white;
  transform: translate(50px, 0) rotate(15deg);      #1
}

Inspect the combined translation and rotation declaration to see how transform order changes the element’s movement. section 16.1.2

How CSS in Depth, Second Edition covers it

How deep it goes
Explains angle direction, units, axes, transform order, and document-flow consequences through a progressively modified card example.
Examples
Demonstrates rotated cards, negative angles, combined translation and rotation, and three-axis rotation diagrams.
What you can do after
Apply it via CSS transform functions, choose suitable angle units and axes, and diagnose unexpected movement caused by transform order.
How it connects
Connects rotation with CSS transforms, translation, scaling, skewing, transitions, animations, and perspective.

Also explained in

Compare how 4 books explain rotation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.