The default value for the position
property is static. It makes the
elements follow the normal flow.
When you set an element's position to relative,
you can move the element to a new location.
The top, right,
bottom and left
properties are used to
note the distance of the new
location from
the original default location.
In the above example, div3's original position
is directly below div2.
But by setting the position value to relative
and using left and top values,
we have pushed it from the left and top by 100px
from its original position.
The top and left properties
wouldn't work if you remove the
position property. These properties
don't work with the static position
elements. You can check this by removing the
position property for div3. Also, try
setting top,right, bottom and left properties
to div2 to see what happens.
Now, take a look at another example:
Relative to its original position, the child element above moves 20px down and 100px to the left when positioned using top: 20px and right: 100px.
To better understand the control we have, let's animate the child element and observe its range of relative positions.
So as you can see from above, the relative positioning property nudges an element from its original position in the specified direction.