CSS UTILITY

CSS Transform Generator

Build CSS transform values visually with translate, rotate, scale, and skew controls. Preview transformations in real-time and copy production-ready code.

0px
0px
0deg
100%
100%
0deg
0deg
Generated CSS
transform: none;

Reshaping Elements Without Breaking Layout

The Four Transform Functions

translate(x, y)moves an element visually without affecting layout — the original space is preserved, and surrounding elements don't reflow. The classic centering trick top: 50%; left: 50%; transform: translate(-50%, -50%) exploits this. rotate(deg) spins around the transform-origin. scale(x, y)resizes without changing the DOM dimensions — a scale(2) element still occupies its original space in the flow. skew(x, y) shears along one or both axes, turning rectangles into parallelograms. All four are GPU-composited and safe for 60fps animation.

Order Matters — Matrix Multiplication

transform: translate() rotate() scale()

Transforms are applied right-to-left as matrix multiplications. transform: translateX(100px) rotate(45deg) first rotates the element 45 degrees, thentranslates 100px along the element's now-rotated X axis (diagonally). Reversing the order — rotate(45deg) translateX(100px)— translates first along the global X axis, then rotates in place. This distinction is critical for orbital animations where an element needs to move in a circle around a point.

transform-origin: The Pivot Point

By default, all transforms pivot around the element's center (50% 50%). Changing transform-origin dramatically alters the behavior of rotate and scale. transform-origin: top left makes rotate(90deg) swing the element around its top-left corner like a door hinge. transform-origin: bottom center makes scaleY(0) collapse the element upward like a window blind. For flip-card effects, use transform-origin: center with rotateY(180deg) and backface-visibility: hidden on both faces.

3D Transforms & Perspective

Adding perspective: 800px to the parent container enables 3D depth for child transforms. Lower values (200-500px) create dramatic, exaggerated perspective; higher values (800-1200px) produce subtle depth. The transform-style: preserve-3d property on a parent lets its children exist in a shared 3D space rather than being flattened. This is essential for card flip effects, 3D carousels, and cube rotations. Without preserve-3d, each child is rendered independently and the 3D illusion breaks.

Frequently Asked Questions

Why does my transformed element overlap other elements without pushing them?

Transforms are applied in the paint phase, afterlayout is calculated. The element's original space in the document flow is preserved. A translated or scaled element is visually moved but its layout footprint stays at the original position. This is by design and is what makes transforms ideal for animation — no expensive reflows. If you need elements to actually reflow, use margin, padding, or change width/height instead.

What is the difference between transform: translate() and position: relative with top/left?

Both move an element visually without affecting siblings, but translate is GPU-composited (runs on the graphics card) while top/left triggers layout recalculation on the CPU. For animations, translate delivers smooth 60fps performance. Additionally, translate accepts percentage values relative to the element itself(translate(-50%, -50%) means “half my own width/height”), while top/left percentages are relative to the containing block. This self-referential sizing is what makes the centering trick work.

How do I create a smooth card flip animation?

Set the parent to perspective: 1000px. Create a wrapper with transform-style: preserve-3d and transition: transform 0.6s. Place two children (front and back) with backface-visibility: hidden, and rotate the back face 180deg by default. On hover, rotate the wrapper 180deg. The backface-visibility property hides the reverse side of each face, creating a clean card-flip illusion.