CKTIS / CSS
transform-origin — the transformation pivot
transform-origin defines the point around which an element rotates or scales. It accepts keywords, lengths, and percentages.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
transform-origin: [ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] <length>? | [ [ center | left | right ] && [ center | top | bottom ] ] <length>?;transform-origin sets the transformation pivot; the property alone does not rotate an element. Its initial value is 50% 50%, and it is not inherited.
One value leaves the other coordinate at center. Two numeric values specify X then Y; an optional third specifies Z and requires a length, not a percentage. Omitted Z is 0px. The keywords left, center, right, top, bottom select the corresponding edges or center; axis-keyword pairs can be reversed, for example top left.
Percentages refer to the reference box selected by transform-box, not the parent. The pivot may lie outside it. For SVG elements without an associated CSS layout box, the initial used value is 0 0.
The example rotates a rectangle around its top-left corner. Transformation changes rendering but does not reflow surrounding content.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Transform origin</title>
<style>
#frame {
position: relative;
margin: 48px;
width: 80px;
height: 40px;
outline: 2px dashed #555;
}
#box {
width: 100%;
height: 100%;
background: #1769aa;
transform-box: border-box;
transform-origin: left top;
transform: rotate(90deg);
}
</style>
</head>
<body>
<div id="frame" role="img" aria-label="Blue rectangle rotated 90 degrees clockwise about the upper-left corner of its original box, shown by a dashed outline.">
<div id="box"></div>
</div>
<script>
const frame = document.getElementById('frame').getBoundingClientRect();
const box = document.getElementById('box');
const rotated = box.getBoundingClientRect();
const relativeX = x => Math.round(x - frame.left);
const relativeY = y => Math.round(y - frame.top);
console.log(`Computed transform-origin: ${getComputedStyle(box).transformOrigin}`);
console.log(`Reference border box (outline excluded): x=0..${frame.width}, y=0..${frame.height}`);
console.log(`Rotated border box relative to reference: x=${relativeX(rotated.left)}..${relativeX(rotated.right)}, y=${relativeY(rotated.top)}..${relativeY(rotated.bottom)}`);
</script>
</body>
</html>Result
Computed transform-origin: 0px 0px Reference border box (outline excluded): x=0..80, y=0..40 Rotated border box relative to reference: x=-40..0, y=0..80
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.