CSS3 2D and 3D Transforms: translate, rotate, scale, skew, transform-origin, perspective and Practical Hover Effects

HTML5 and CSS3 50 min min read Updated: Nov 17, 2026 Beginner
CSS3 2D and 3D Transforms: translate, rotate, scale, skew, transform-origin, perspective and Practical Hover Effects
Beginner Topic 1 of 3

What Is a Transform?

transform changes how an element is drawn (moved, turned, resized) without changing the space it takes in the layout. That makes it fast and smooth.

FunctionEffectExample
translate(x, y)Movetranslate(20px, -10px)
rotate(angle)Turnrotate(45deg)
scale(n)Make bigger or smallerscale(1.1)
skew(x, y)SlantskewX(10deg)
css .box { transform: translate(20px, 10px); } .spin { transform: rotate(15deg); } .big { transform: scale(1.2); } .combo { transform: translate(10px, 20px) rotate(90deg) scale(2); }

Functions apply in order, right to left in terms of the math. If results look odd, change the order.

Measured in Chrome

computed transform for translate(10px, 20px) rotate(90deg) scale(2): matrix(0, 2, -2, 0, 10, 20)

transform-origin

css .door { transform-origin: left center; transform: rotateY(40deg); } .hand { transform-origin: bottom center; transform: rotate(30deg); }

The origin is the point the transform happens around. The default is the center.

Hover Effects

css .card { transition: transform .2s ease, box-shadow .2s ease; } .card:hover, .card:focus-within { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0, 0, 0, .15); }

A Simple Centered Overlay

css .badge { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

top: 50% moves the top-left corner to the middle. translate(-50%, -50%) moves the element back by half its own size, so it is truly centered.

3D Transforms

css .scene { perspective: 800px; } .flipper { transition: transform .6s; transform-style: preserve-3d; } .scene:hover .flipper { transform: rotateY(180deg); } .face { position: absolute; inset: 0; backface-visibility: hidden; } .back { transform: rotateY(180deg); }
PropertyUse
perspectiveOn the parent. Smaller value means stronger 3D
transform-style: preserve-3dChildren keep their 3D position
backface-visibility: hiddenHide the back of a flipped face
Respect motion settings Big moving effects can bother some people. Turn them off with @media (prefers-reduced-motion: reduce).
css @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

Practice

  1. Make a card that lifts on hover
  2. Center a badge with the translate trick
  3. Build a card that flips on hover

Conclusion

Transforms move, turn and scale elements smoothly. Use them for hover effects and respect reduced motion.

Quick Summary: Functions; origin; hover; centering; 3D; reduced motion.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators