Yogesh Chauhan's Blog

transform-origin Property in CSS

in CSS on February 16, 2021

transform-origin property to me is like hanging the object on a point and then using that point as a center to move the object.

The transform-origin property let us change the position of elements with transform property set.

If we have elements with 2D transformations set then we can pin the transform-origin point to move those elements in x- and y-axis. We can also do that for z-axis if we have 3D transformations set for an element.

transform-origin property has a default values of 50% 50% 0

That value is always set unless we define something else to be set.

As we can see that by default it pins the elements in the center of the element so when we ONLY specify the transform property, it will adjust according to that default pin set.

And if we move that pin using transform-origin property then it will use that new pin point to adjust the elements on x or y or z axis depending on the transform-origin property value.

All major browsers support it so feel free to use it.


transform-origin: x-axis y-axis z-axis|initial|inherit;

x-axis and y-axis possible values are left, center, right, length and % but for z-axis only one possible value is length.


transform-origin: center

transform-origin: top left

transform-origin: 25% 25%

transform-origin: top left, transform: skewX(50deg)

Source: w3.org

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to set the permissions on all files and folders in Mac?MiscellaneousHow to Use SQL MAX() Function with Dates?SQL/MySQLHow to Use the EXISTS and NOT EXISTS Operator with a Subquery in SQL and MySQL?SQL/MySQLCreate a galley with overlapping images using CSS gridCSSWhat are “holes” in a React component?ReactHow to create a multisite network in WordPress?WordPress