Transform Origin
suggest changeTransformations are done with respect to a point which is defined by the transform-origin property.
The property takes 2 values : transform-origin: X Y;
In the following example the first div (.origin1) is rotated around the top left corner with transform-origin: 0 0; and the second (.origin2) is transformed around its top right corner with transform-origin: 100% 0. The rotation is applied on hover:
HTML:
<div class="transform origin1"></div>
<div class="transform origin2"></div>
CSS:
.transform {
display: inline-block;
width: 200px;
height: 100px;
background: teal;
transition: transform 1s;
}
.origin1 {
transform-origin: 0 0;
}
.origin2 {
transform-origin: 100% 0;
}
.transform:hover {
transform: rotate(30deg);
}
The default value for the transform-origin property is 50% 50% which is the center of the element.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents