I am really struggling to understand the concept of relative versus absolute
positioning, especially when dealing with parent or grandparent elements that have position values. Can someone please help me clarify these two scenarios:
Case 1:
- grandparent - absolute
- parent - relative
- child - absolute
Case 2:
- grandparent - absolute
- parent - relative
- child - absolute
However, in this case, the parent is not directly nested within the grandparent like shown below:
<div class="grand-parent">
</div>
<div class="parent">
<div class="child">
</div>
</div>
Here is a link to a fiddle where I've been working on this issue: https://jsfiddle.net/4KUWc/32/
My questions are:
- I'm having trouble seeing the difference between the two cases mentioned above. Shouldn't case 2 have the parent div start after the grandparent? Why does it seem to take (0,0) coordinates?
- If a relative element has an absolute parent, will it follow the positioning of the absolute parent or will it maintain its independence?
- Is it possible to have relative children with an absolute parent?