CSS Transforms
Published by
sanya sanya
CSS transforms allow you to manipulate the position, size, and orientation of elements on a web page. They enable you to perform 2D and 3D transformations, such as rotating, scaling, skewing, and translating elements.
CSS transforms are applied using the transform property. Every aspect and type related to the CSS Transforms are discussed further.
2-D Transforms
All the key aspects related to the 2-D Transforms are mentioned below -
- Translation - translate() moves an element along the X and Y axes.
- Rotation - `rotate()` rotates an element clockwise around a fixed point.
- Scaling - scale() changes the size of an element along the X and Y axes.
- Skewing - skew() tilts an element along the X and Y axes.
- Origin - transform-origin specifies the origin point for the transformation.
.element { transform: translate(100px, 50px) rotate(45deg) scale(1.2) skew(10deg, 5deg); transform-origin: top left; }
3-D Transforms
All the key aspects related to the 3-D Transforms are mentioned below -
- Translation - translate3d() moves an element in 3D space.
- Rotation - rotate3d() rotates an element around an arbitrary 3D vector.
- Scaling - scale3d() changes the size of an element in 3D space.
- Perspective - perspective sets the perspective view for 3D transforms.
.element { transform: translate3d(100px, 50px, 0) rotate3d(1, 1, 0, 45deg) scale3d(1.2, 1.2, 1) perspective(1000px); }
Transform Origin
The transform-origin property defines the origin point around which the transformation is performed.
It accepts values in pixels, percentages, or keywords like top, bottom, left, right, center, etc.
.element { transform-origin: 50% 50%; }
Transform Shorthand
The transform property can be specified as a shorthand to combine multiple transformations in a single declaration.
.element { transform: translate(100px, 50px) rotate(45deg) scale(1.2); }
Library
WEB DEVELOPMENT
Basic
HTML - Hyper Text Markup Language
CSS - Cascading Style Sheets
Cascading Style Sheets (CSS)
Selectors and Combinators
CSS Transforms
Units
CSS Icons and Colors
CSS Borders
CSS Margin
CSS Padding
CSS Dimensions
CSS Box Model
CSS Background
Pseudo Classes in CSS
CSS Positions
CSS Flexbox
Responsiveness in CSS
CSS Transitions
CSS Animations
Other CSS Properties
Var()
CSS Frameworks
CSS Grids
CSS Display Properties
JavaScript
Frontend
Backend
Interview Questions
FAANG QUESTIONS
On this page
2-D Transforms
3-D Transforms
Transform Origin
Transform Shorthand

