Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

rotateX(): tilt around the horizontal axis

Move points between the y and z directions while retaining the x coordinate and the original layout height.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

transform: rotateX(60deg);

The function rotateX() rotates around the x axis and is equivalent to rotate3d(1, 0, 0, angle). Its argument is an angle, or a unitless zero. With the origin at zero, the x coordinate stays unchanged while y and z are mixed by the rotation. Under the usual CSS convention, positive z points towards the viewer: a positive quarter-turn therefore moves a point on the positive y axis towards positive z.

The default center of rotation and the chosen transform-origin can produce different placement even with the same angle. Perspective is optional and affects how depth projects onto the screen. backface-visibility separately controls the reverse side; it does not define the rotation or make it accessible. Motion-heavy interfaces should respect reduced-motion preferences, and important content should not rely solely on a tilted or hidden face.

The example fixes the origin at zero and omits perspective. A positive 90-degree turn changes 5,10,0 to 5,0,10; the negative turn gives 5,0,-10. The equivalent axis function yields the same positive result. At 60 degrees, the box’s layout height remains 80px while its projected bounding height is 40px. At 90 degrees the measured height is zero because this flat box is edge-on. That observation is not a general promise that every nested, thick or perspective-transformed object becomes invisible.

Examples

const box = document.createElement('div');
box.style.cssText = 'width:100px;height:80px;transform-origin:0 0';
document.body.append(box);
function point(transform) {
  box.style.transform = transform;
  const p = new DOMMatrix(getComputedStyle(box).transform).transformPoint(new DOMPoint(5,10,0));
  return [p.x,p.y,p.z].map(n => Number(n.toFixed(6))).join(',');
}
console.log('+90:', point('rotateX(90deg)'));
console.log('-90:', point('rotateX(-90deg)'));
console.log('axis equivalent:', point('rotate3d(1,0,0,90deg)'));
box.style.transform = 'rotateX(60deg)';
console.log('layout height:', box.offsetHeight);
console.log('projected height:', Number(box.getBoundingClientRect().height.toFixed(6)));
box.style.transform = 'rotateX(90deg)';
console.log('edge-on height:', Number(box.getBoundingClientRect().height.toFixed(6)));
box.remove();

Result

+90: 5,0,10
-90: 5,0,-10
axis equivalent: 5,0,10
layout height: 80
projected height: 40
edge-on height: 0

The measurements concern a flat rectangle without perspective. They verify coordinates and bounding geometry, not back-face painting, screen-reader behavior or a complete animated interface.

Sources