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.
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.
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
.
- index.html
- style.css
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.
Move the .fence-1
block:
- Rotate the object clockwise
90°
:transform: rotate(90deg)
. - Move the object up
25px
. - And nudge the object to the right by
50px
so that it merges with the first part of the fence.
- Position the second part of the fence in its place (close to the fence from the side of the house).
Comments