HTML Academy
Increasing and decreasing the size
2D Transforms5/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
The beginning of the journey
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Defending the city

So the time has now come for us to put the knowledge that we gained to good use: early in the morning, a wolf attacked the city where Pendalf lives!

In the midst of all of the confusion, our wizard was not able to conjure up any fireballs, so now we need to urgently repair the collapsed fence.

To do this, you need to collect your wits and quickly remember everything you know. You will also need to master a couple of new techniques.

How the rotate function works

In this assignment, we need a transform with the transform: rotate rotation function. Its syntax is as follows: transform: rotate(skew angle).

A positive value for the angle will rotate the object clockwise, while a negative angle will rotate it counterclockwise. The rotation unit is the degree (deg). For example, transform: rotate(180deg) will rotate the object 180° clockwise. In other words, it will flip it.

There is just one subtle detail to keep in mind when applying rotation and movement transforms at the same time. When you rotate an object by a given angle, its entire coordinate system rotates together with it.

How the rotate function works

In other words, to make sure that a block that has been rotated 90° moves horizontally, we need to apply translateY. If instead we wanted the block to move vertically, then we would apply translateX.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Defending the city</title> <meta charset="utf-8"> <link rel="stylesheet" href="world.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="world"> <div class="house"></div> <div class="wizard"></div> <div class="fence fence-1"></div> <div class="fence fence-2"></div> <div class="fence-old"></div> <div class="wolf"></div> </div> </body> </html>
CSS
.wizard { top: 245px; left: 60px; } .fence-1 { }

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

    Move the .fence-1 block:

    1. Rotate the object clockwise 90°: transform: rotate(90deg).
    2. Move the object up 25px.
    3. And nudge the object to the right by 50px so that it merges with the first part of the fence.
    1. Position the second part of the fence in its place (close to the fence from the side of the house).

    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.