PureDevTools

CSS Transform Playground

Build CSS transform chains visually — add, reorder, and adjust transform functions with sliders, live preview, transform-origin control

All processing happens in your browser. No data is sent to any server.

Presets

Transform Chain(2 functions)

0deg
0px

Transform Origincenter center

Live Preview

CSS Transform

Preview updates in real time as you adjust values.

CSS Output

.element {
  transform: rotateZ(0deg) translateX(0px);
  transform-origin: center center;
}

transform value only

rotateZ(0deg) translateX(0px)

Your card hover effect needs a simultaneous translateY(-4px) rotate(1deg) scale(1.02) — three transforms chained in one declaration. The order matters: rotate before translate produces a different result than translate before rotate, because each function operates in the coordinate space modified by the previous one. You need to see each function’s effect as you add it, not guess from the spec.

Why This Playground (Not Just Guessing Transform Values)

Transform chains are composable but order-dependent, and the interaction between transform-origin, perspective, and the function order is impossible to predict from the syntax alone. This playground lets you add functions from a list, reorder them by dragging, adjust values with sliders, and see the live preview update frame-by-frame. Everything runs in your browser; no data is sent anywhere.

What Is CSS Transform?

CSS transforms let you move, rotate, scale, skew, and add 3D perspective to any element — without affecting the document layout. They are GPU-accelerated, making them the most performant way to animate position and appearance.

How to Use This Tool

  1. Choose a preset — start with Flip Card, Tilt 3D, Scale & Rotate, Skew, Slide In, or Mirror
  2. Add a transform function — click “Add Function” and choose from the dropdown: translate, rotate, scale, skew, or perspective
  3. Adjust the value — use the slider or type directly into the number input
  4. Reorder functions — use the up/down buttons to change the order (order matters in CSS transforms)
  5. Remove a function — click the × button to delete a transform function from the chain
  6. Set transform-origin — choose the X and Y anchor point (top/center/bottom, left/center/right)
  7. Watch the live preview — a sample element updates in real time
  8. Copy the CSS — copy the full .element { transform: ...; transform-origin: ...; } block

The transform Property

CSS transforms combine multiple functions in a single transform declaration:

.element {
  transform: translateX(50px) rotateZ(45deg) scale(1.2);
  transform-origin: center center;
}

The browser applies each function from right to left in the rendered output, but the order you write them matters — because each transform creates a new coordinate system for the next one.

Available Transform Functions

FunctionUnitEffect
translateX(n)pxMoves element horizontally
translateY(n)pxMoves element vertically
translateZ(n)pxMoves element along Z axis (needs perspective)
rotateX(n)degRotates around X axis (needs perspective for 3D effect)
rotateY(n)degRotates around Y axis (needs perspective for 3D effect)
rotateZ(n)degRotates in 2D (equivalent to rotate(n))
scaleX(n)Scales element width (1 = original, -1 = mirror)
scaleY(n)Scales element height
scaleZ(n)Scales along Z axis (needs perspective)
skewX(n)degSkews element horizontally
skewY(n)degSkews element vertically
perspective(n)pxSets 3D perspective depth — must come first in chain

Order Matters in Transform Chains

Unlike CSS properties that are independent, transform functions compose — each one modifies the coordinate system for the next:

/* Rotates in place, then moves 100px in the rotated direction */
transform: rotateZ(45deg) translateX(100px);

/* Moves 100px right first, then rotates the entire group */
transform: translateX(100px) rotateZ(45deg);

These produce different visual results. Use the up/down reorder buttons to experiment with different orderings.

3D Transforms and Perspective

To create 3D depth effects, you need perspective. There are two ways to apply it:

Method 1: perspective() function (local)

Add perspective(n) as the first function in the transform chain. This applies perspective only to that element.

.element {
  transform: perspective(600px) rotateY(45deg);
}

Method 2: perspective property (parent)

Apply perspective to the parent element. All children share the same vanishing point — useful for 3D card grids.

.container {
  perspective: 600px;
}
.card {
  transform: rotateY(45deg);
}

Perspective value guidelines:

transform-origin

The transform-origin property sets the anchor point for all transforms. Rotation and scaling happen relative to this point.

/* Rotate from the top-left corner */
.element {
  transform-origin: left top;
  transform: rotateZ(45deg);
}

/* Scale from the bottom-right corner */
.element {
  transform-origin: right bottom;
  transform: scale(1.5);
}

Common use cases:

Performance: Why Transforms Are GPU-Accelerated

CSS transform and opacity are the only properties browsers animate on the compositor thread — a separate thread from the main JavaScript thread. This means:

/* GPU-accelerated — always prefer this for animations */
.element {
  transform: translateX(100px);
}

/* NOT GPU-accelerated — causes layout + paint on every frame */
.element {
  left: 100px;
}

Tip: Use will-change: transform to hint the browser to promote the element to its own compositor layer before the animation starts:

.card {
  will-change: transform;
  transition: transform 300ms ease;
}
.card:hover {
  transform: rotateY(10deg) scale(1.05);
}

Use will-change sparingly — it increases GPU memory usage.

Shorthand Functions: translate(), scale(), rotate()

CSS has shorthand functions for common 2D operations:

ShorthandEquivalent
translate(x, y)translateX(x) translateY(y)
scale(x, y)scaleX(x) scaleY(y)
rotate(deg)rotateZ(deg)
skew(x, y)skewX(x) skewY(y)

For 3D operations, you must use the individual axis functions.

Common Transform Patterns

Centered Flip Animation

.card {
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}
.card:hover {
  transform: perspective(600px) rotateY(180deg);
}

Hover Lift Effect

.button {
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}
.button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

Diagonal Slide In

.element {
  transform: translateX(-100px) translateY(-50px) rotateZ(-5deg);
  opacity: 0;
  transition: transform 400ms ease-out, opacity 400ms ease;
}
.element.visible {
  transform: none;
  opacity: 1;
}

Mirror Effect

.mirrored {
  transform: scaleX(-1);
}

Frequently Asked Questions

What is the difference between transform and position for animation? transform is GPU-accelerated — the browser animates it without triggering layout or paint. Changing top, left, margin, or width triggers layout recalculation on every frame, which is much more expensive and can cause jank.

Why doesn’t my 3D transform look 3D? 3D transforms require perspective to project the 3D scene onto the 2D screen. Add perspective(600px) as the first function in your transform chain, or set perspective: 600px on the parent element.

Why does order matter in transform chains? Each transform function establishes a new local coordinate system. rotateZ(45deg) translateX(100px) moves the element 100px in the rotated direction (diagonal). translateX(100px) rotateZ(45deg) moves it 100px right then rotates the whole thing in place.

What is transform-style: preserve-3d? By default, child elements don’t participate in 3D space. Setting transform-style: preserve-3d on a parent lets its children be positioned in the same 3D space — required for 3D card flips where front and back faces must be in the same scene.

Can I animate transform with JavaScript? Yes. Use the Web Animations API for smooth control:

element.animate(
  [{ transform: 'rotate(0deg)' }, { transform: 'rotate(360deg)' }],
  { duration: 1000, iterations: Infinity }
);

Or update a CSS custom property:

element.style.setProperty('--rotate', `${angle}deg`);
.element { transform: rotate(var(--rotate, 0deg)); }

What is the matrix() function? matrix(a, b, c, d, tx, ty) and matrix3d() are the low-level representations that the browser uses internally. All transform functions — translate, rotate, scale, skew — are converted to matrix operations before rendering. You rarely need to write matrix values by hand.

Related Tools

More CSS Tools