Interactive online courses HTML Academy
2026-03-09 14:06 Diff

In this chapter, we will explore the capabilities of 2D transforms in CSS.

What previously could only be done in a browser window using JavaScript (smoothly rearranging and scaling blocks as well as rotating and skewing them) can now easily be implemented in pure CSS.

First, let’s understand the coordinate system in which the object is moved:

The key feature to keep in mind is that the Y-axis is directed downward, not upward, since the web page starts at the top-left corner and then flows downward, and CSS uses the inverse coordinate system.

The first movement we make is horizontal. We will move objects left and right.

We use the following syntax to make this and other transforms:

transform: the transform function (transform value)

You can move an object horizontally using the translateX function. The transform function takes a numerical value, and the possible units of measurement are px, %, em, or in.
For example, this function will move the object 100 pixels to the right along the X-axis:

transform: translateX(100px)

By the way, let’s get acquainted! The main character that you will be asked to control and to transform his world using spells is called Pendalf the Blue. You will go on an exciting adventure together with him…