The transform-origin property defines the pivotal point around which a CSS transform happens.
It affects transforms such as rotate(), scale(), and skew().
By default, the transform happens around the center of an element:
We can see how it works in the following image:

Here, the button scales from its center.
But in this case, scaling from the left makes more sense:

Defining the pivot point
As you can see in the previous example you can use keywords such as top, right, bottom, and left to define this point and you can also combine two keywords (left, center).
You can also use percentages and fixed lengths
Percentages give you more control over the exact position.
The first value controls the horizontal position while the second controls the vertical position.
In this example, the origin is one-quarter horizontally and three-quarters vertically.
You can also use lengths
These values place the origin 10px from the left and 30px from the top.
We can use a third value for controlling depth. This is useful in cases where we want to use 3D transforms.
Common mistakes and how to avoid them
1. Confusing transform-origin with transform
transform-origin sets the pivot point but it does not animate an element by itself.
For doing so you need both properties.
2. Reversing the values
As we have seen so far, the transform-origin property takes three values. The first value represents the x-axis, the second the y-axis and the third the z-axis. You must be aware of that when setting the values. Otherwise you may be surprised expecting something different from what you get.
3. Forgetting the default value
If you do not set a value for the transform-origin, the browser will use the center as default.
For a different effect, you should set your values explicitly.
4. Changing the transform-origin during an animation and not before
If transform-origin changes while an element is animating, the motion can look unexpected or take no effect at all.
Here, when hover begins, transform-origin changes from the center to the left edge at the same time as the scale animation. This can make the fill appear to jump or to begin from the center to the left and not vice versa as you originally wished.
You should set the values before the animation begins.
Conclusion
The transform-origin property changes the pivotal point of a visual transformation while keeping the normal position of the element in the page as is. This makes it useful for animating elements from a particular spot, other than the center which is the default.