codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🎨

HTML & CSS

30 / 59 topics
28CSS Animation29CSS Transitions30CSS Transforms31CSS Variables32CSS Pseudo-elements33CSS Pseudo-classes
Tutorials/HTML & CSS/CSS Transforms
🎨HTML & CSS

CSS Transforms

Updated 2026-05-15
10 min read

CSS Transforms

Introduction

CSS transforms are a powerful feature that allow developers to manipulate the position, size, and orientation of HTML elements. By using CSS transforms, you can create dynamic and interactive web pages without relying heavily on JavaScript for basic visual effects. This tutorial will introduce you to the basics of CSS transforms and how they can be used to enhance your web designs.

Concept

CSS transforms enable you to apply 2D or 3D transformations to elements. These transformations include scaling, rotating, skewing, and translating (moving) elements. The transform property is used to specify the transformation to apply to an element. You can combine multiple transformations by separating them with spaces.

Common Transform Functions

  • translate(x, y): Moves an element by a specified number of pixels along the x-axis and y-axis.
  • rotate(angle): Rotates an element clockwise by a given angle in degrees.
  • scale(sx, sy): Scales an element by a specified factor along the x-axis and y-axis. If only one value is provided, it scales both axes equally.
  • skew(ax, ay): Skews an element by a specified angle along the x-axis and y-axis.

Examples

1. Basic Translation

Let's start with a simple example where we move an element using the translate function.

CSS
1.box {
2width: 100px;
3height: 100px;
4background-color: blue;
5transform: translate(50px, 100px);
6}

In this example, the .box element is moved 50 pixels to the right and 100 pixels down.

2. Rotation

Next, let's rotate an element using the rotate function.

CSS
1.box {
2width: 100px;
3height: 100px;
4background-color: red;
5transform: rotate(45deg);
6}

This code rotates the .box element by 45 degrees clockwise.

3. Scaling

Now, let's scale an element using the scale function.

CSS
1.box {
2width: 100px;
3height: 100px;
4background-color: green;
5transform: scale(2);
6}

This code scales the .box element by a factor of 2, making it twice as large.

4. Skewing

Finally, let's skew an element using the skew function.

CSS
1.box {
2width: 100px;
3height: 100px;
4background-color: yellow;
5transform: skew(30deg, 20deg);
6}

This code skews the .box element by 30 degrees along the x-axis and 20 degrees along the y-axis.

What's Next?

In this tutorial, we covered the basics of CSS transforms, including translation, rotation, scaling, and skewing. These transformations are fundamental to creating dynamic and interactive web designs. In the next section, we will explore how to use HTML Iframes to embed external content within your web pages.


PreviousCSS TransitionsNext CSS Variables

Recommended Gear

CSS TransitionsCSS Variables