I am trying to understand positioning and regarding absolute
I have a problem.
For what I understand, absolutely positioned elements are completely removed from the normal document flow. As far as the elements around them are concerned the absolutely positioned element doesn’t exist.
Then, they are positioned in relation to the first parent element it has that doesn't have position: static;
. If there's no such element, the element with position: absolute gets positioned relative to <html>
.
So here I have created a fiddle with 3 different divs, each of them with one color. All three have an opacity of 0.5. --> https://jsfiddle.net/uwqoy4zh/
When I set the second div to position: absolute, he is removed from the flow and therefore I see the pink one on its place --> https://jsfiddle.net/401ykurg/
However, when I do exactly the same thing but whitout changing the opacity, the one that is removed from the flow is the pink one! --> https://jsfiddle.net/qnou6Lya/
What I am not understading?
Also, I can see that in the example that does work (where it removes the yellow one from the flow) where is actually position is behind the pink one, not the blue.
I can see this when making the yellow a bit wider --> https://jsfiddle.net/tszm65cu/
If absolutely positioned are positioned in relation to the first parent element it has that doesn't have position: static
and when there's no such element, the element with position: absolute
gets positioned relative to the document window, why doesn't it position the yellow div underneath the blue one?
The yellow does not have a top or anything, and since there's no parent element with absolute, relative, or fixed positioning applied, it should place it in relatin to the window.
Why is it there?
Thanks!