Relative Position
Besides display, the layout of a page is affected by the property position. To see clearly what it does, we'll try it on a simple page with three squares for a while. We'll come back to the cat page later.
The default value of position is static. A static element stays exactly where normal flow puts it. All the elements you've seen so far were static.
An element with position: relative stays in normal flow too, but unlike a static one, it can be moved from its place with the properties top, right, bottom and left, called offsets. Each offset says how far the element moves away from that side of its original place: top: 30px moves it 30 pixels down, left: 30px moves it 30 pixels to the right.
The other elements don't notice the move. They behave as if the element were still in its original place, so its space stays empty.
In the editor, the squares are div elements with display: inline-block, so they stand in a row. The second one has the id square2.
Instructions
- 1
In the rule for
#square2, add the declarationsposition: relativeandtop: 30px. The red square moves 30 pixels down. - 2
In the same rule, add
left: 30px. The red square also moves 30 pixels to the right and partly covers the third square. The third square stays where it was, because for the other elements, the red square is still in its original place.