HTML Academy
The final battle
2D Transforms14/32
Back to the list of tasks
  • 1. Moving objects horizontally
  • 2. Moving objects vertically
  • 3. Fireball training
  • 4. Increasing and decreasing the size
  • 5. Defending the city
  • 6. The beginning of the journey
  • 7. The maze
  • 8. The battle, part 1
  • 9. The battle, part 2
  • 10. Test: The mysterious card
  • 11. The battle, part 3
  • 12. Test: The shattered crystal
  • 13. The final battle
  • 14. Features of transform-origin, part 1
  • 15. Features of transform-origin, part 2
  • 16. Features of transform-origin, part 3
  • 17. Features of transform-origin, part 4
  • 18. Centering with transform: translate
  • 19. Rotating the text in blocks
  • 20. Rotating the text in the background
  • 21. Custom shadows
  • 22. On-hover effects: buttons, part 1
  • 23. On-hover effects: buttons, part 2
  • 24. On-hover effects: buttons, part 3
  • 25. On-hover effects: the gallery
  • 26. The “stack” of cards
  • 27. Preparing the round menu
  • 28. Round menu, step 1
  • 29. Round menu, step 2
  • 30. Round menu, step 3
  • 31. The round menu, final part
  • 32. Test: Arranging the cards
Features of transform-origin, part 2
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Features of transform-origin, part 1

Now that the ancient evil power has been defeated, and Pendalf has made it back home, it’s time to figure out another subtle detail of how transforms work, namely the transform-origin property. (And let’s also hang a commemorative photo on the wall).

This property is used in conjunction with the transform property to assign the origin of the coordinate system that will be used to perform the transforms.

The transform-origin syntax for 2D transforms is as follows:

transform-origin: origin-along-X-axis [origin-along-Y-axis]

The property values are specified in the browser using width units (px, em…), as a %, and also using the keywords left, right, top, bottom and center.

By default, the value of transform-origin is equal to 50% 50%, that is, the origin of the coordinate system is at the center of the object. If you do not specify the value of origin-along-Y-axis, then it is considered equal to 50%.

Let’s take a look at the scale function in the example and how the transform behaves with different values of transform-origin: in this case, the block will be resized relative to the given point.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Features of transform-origin, part 1</title> <meta charset="utf-8"> <link rel="stylesheet" href="world.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="world homeworld"> <div class="picture-frame active"> <div class="picture"></div> </div> </div> </body> </html>
CSS
.picture { }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Set the transform property to the value scale(0.5deg) for the .picture block,
    2. and then set the transform-origin property to the value top left.
    3. And change the value of transform-origin to top right.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.