Forum Moderators: not2easy
position: relative;
left: 25px;
...would move the element 25 pixels to the right, relative to where it would be located if not positioned at all.
You already know that absolute positioning allows elements to overlap each other, being taken out of the normal page flow, not affecting surrounding elements at all. Relative positioning basically only moves the "projection" of the element, leaving an empty box where the element was originally located. This can be used to create neat effects:
<span style="background-color:#666;"><img src="http://www.google.com/images/logo.gif" style="position:relative; top:-3px; left:-3px;"></span>
Is there any situation where relative is betetr than absolute, apart formn the effects you can get?
I have found that absolute is pretty stable across browsers but relative (where I have tried to use it but I'm unsure exactly what rel positioning is doing) seems a bit flaky and falls over a lot.
position:relative, but with no top or left values (or explicitly set them to zero). Voila! The parent is now positioned, though not moved, and the child can be positioned within it's parent's boundaries.
I did a write-up of this in a long-ago post:
[webmasterworld.com...]
(I've also placed a copy of this on my personal website.)