CSS transform-origin Property Last Updated : 04 Aug, 2023 Comments Improve Suggest changes Like Article Like Report The transform-origin property of CSS is used to specify the origin of the rotation of an element. It is the point at which an element is rotated. It can be used for both 2D and 3D rotations. Syntax: transform-origin: position | initial | inheritProperty Values: position: This specifies the position of the origin of rotation. It takes 3 values corresponding to the distance from the left edge of the box, the distance from the top edge of the box, and the z-axis of rotation. The values could be specified in length units, percentages or keywords. The z-axis value is always specified using length units. initial: This is used to set the property to its default value. inherit: This is used to inherit the property from its parent. Example 1: Specifying the position in length units html <!DOCTYPE html> <html> <head> <style> .outer { margin: 50px; border: 1px dotted; position: relative; height: 100px; width: 400px; background-color: lightgreen; } .box { position: absolute; border: 1px solid; background: url( "https://write.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png") no-repeat; background-size: cover; height: 100px; width: 400px; transform: rotate(15deg); transform-origin: 10px 30px; } </style> </head> <body> <h1>CSS transform-origin Property</h1> <p> The CSS transform-origin Property is used to set the origin of the element's transformation </p> <div class="outer"> <div class="box"></div> </div> </body> </html> Output: Example 2: Specifying the position in percentage html <!DOCTYPE html> <html> <head> <style> .outer { margin: 50px; border: 1px dotted; position: relative; height: 100px; width: 400px; background-color: lightgreen; } .box { position: absolute; border: 1px solid; background: url( "https://write.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png") no-repeat; background-size: cover; height: 100px; width: 400px; transform: rotate(15deg); transform-origin: 50% 75%; } </style> </head> <body> <h1>CSS transform-origin Property</h1> <p> The CSS transform-origin Property is used to set the origin of the element's transformation </p> <div class="outer"> <div class="box"></div> </div> </body> </html> Output: Example 3: Specifying the position in keywords html <!DOCTYPE html> <html> <head> <style> .outer { margin: 50px; border: 1px dotted; position: relative; height: 100px; width: 400px; background-color: lightgreen; } .box { position: absolute; border: 1px solid; background: url( "https://write.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png") no-repeat; background-size: cover; height: 100px; width: 400px; transform: rotate(15deg); transform-origin: bottom left; } </style> </head> <body> <h1>CSS transform-origin Property</h1> <p> The CSS transform-origin Property is used to set the origin of the element's transformation </p> <div class="outer"> <div class="box"></div> </div> </body> </html> Output: Example: In this example, we are using transform-origin: initial property. html <!DOCTYPE html> <html> <head> <style> .outer { margin: 50px; border: 1px dotted; position: relative; height: 100px; width: 400px; background-color: lightgreen; } .box { position: absolute; border: 1px solid; background: url( "https://write.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png" ) no-repeat; background-size: cover; height: 100px; width: 400px; transform: rotate(15deg); transform-origin: initial; } </style> </head> <body> <h1>CSS transform-origin Property</h1> <p> The CSS transform-origin Property is used to set the origin of the element's transformation </p> <div class="outer"> <div class="box"></div> </div> </body> </html> Output: Example: In this example, we are using the transform-origin: inherit property. html <!DOCTYPE html> <html> <head> <style> /* this acts as the parent */ .outer { margin: 50px; border: 1px dotted; position: relative; height: 100px; width: 400px; background-color: lightgreen; /* set the property of the parent */ transform-origin: bottom left; } .box { position: absolute; border: 1px solid; background: url( "https://write.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png" ) no-repeat; background-size: cover; height: 100px; width: 400px; transform: rotate(15deg); /* inherits the property of the parent */ transform-origin: inherit; } </style> </head> <body> <h1>CSS transform-origin Property</h1> <p> The CSS transform-origin Property is used to set the origin of the element's transformation </p> <div class="outer"> <div class="box"></div> </div> </body> </html> Output: Supported Browsers: The browser supported by transform-origin property are listed below: Chrome 36.0Edge 12.0Firefox 16.0Safari 9.0Opera 23.0 Comment More infoAdvertise with us Next Article JavaScript Tutorial S sayantanm19 Follow Improve Article Tags : Web Technologies CSS CSS-Properties Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i 6 min read Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc 15+ min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Like