rotateY()

Term side of the Card.
Topic: Transformations
Unit title: rotateY()
Categories: Function
Explanation side of the Card

Explanation: The function that applies a 3D rotation to an element around the Y-axis. This transformation swivels the element left or right, making it appear as though the element is rotating around a vertical line running from top to bottom.

Browser compatibility:
  • The chrome browser supports this feature starting from version 12.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 10.
  • The safari browser supports this feature starting from version 4.
Availability: 

Example

Wrongcss
.front,
.back {
  position: absolute;
  inset: 0;
}
.back {
  transform: rotateY(180deg);
}
Rightcss
.front,
.back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}
.back {
  transform: rotateY(180deg);
}

backface-visibility: hidden hides each face when it turns away, so only one side shows at a time.

Common mistakes

  • The back of the card shows mirrored front text.
  • The flip works only with a mouse, never on touch or keyboard.

Key points

  • The back face is pre-rotated with rotateY(180deg) and both faces have backface-visibility: hidden.
  • A perspective is set on the container of the flipping element.
  • The flip also works on keyboard focus, not only on :hover.

Interview questions

Does rotateY() work without perspective?

It works, but looks flat: the element only gets narrower while turning, with no 3D depth.

Why do my flip card faces flicker?

Usually transform-style: preserve-3d is missing on the rotating parent, so the faces are flattened into one plane.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy