CSS Transforms

Move, rotate, scale and skew elements.

✍️ 3 exercises + code challenge in this lesson

The transform property changes the shape and position of an element without affecting the layout around it.

  • translate(x, y): move.
  • rotate(45deg): rotate.
  • scale(1.5): resize.
  • skew(10deg, 5deg): slant.

Several functions can be combined: transform: translateX(20px) rotate(10deg);. 3D transforms such as rotateY() also exist.

Key Takeaways: CSS Transforms

Mastering CSS Transforms helps you write clean and reliable CSS code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

CSS Transforms Code Example

CSS
<style>
  .row { display: flex; gap: 30px; padding: 30px; }
  .box { width: 80px; height: 80px; background: #2563EB; color: white; display: grid; place-items: center; border-radius: 10px; font: 12px Arial; }
  .t1 { transform: translateY(20px); }
  .t2 { transform: rotate(30deg); background: #14B8A6; }
  .t3 { transform: scale(1.3); background: #E34F26; }
  .t4 { transform: skew(15deg, 5deg); background: #EAB308; }
</style>

<div class="row">
  <div class="box t1">translate</div>
  <div class="box t2">rotate</div>
  <div class="box t3">scale</div>
  <div class="box t4">skew</div>
</div>
Free sign-in required · Google login available

CSS Transforms Practice Exercises

Check what you learned in “CSS Transforms”.

/ 3 solved
Fill in the blank

Rotate the element by 45 degrees.

.box {
  transform: (45deg);
}
✓ Correct! Not quite. Try again.
Multiple choice

Which transform function makes an element larger?

✓ Correct! Not quite. Try again.
Code challenge

Scale the box to twice its size using transform.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services