Hi!
Because it removes the element from the standard document flow.
In a normal document flow if not overriden by CSS a div takes 100% of its parent’s container.
After the element is positioned absolutely and removed from the document flow, it takes a min eidth which is defined by the browser. If the content is larger than this width the it will take the required place to display its content.
So we have to specify the width of the absolutely positioned element manually.
Thank you for this. Please why did the second div's width get smaller when you gave it a position of absolute?
Hi!
Because it removes the element from the standard document flow.
In a normal document flow if not overriden by CSS a div takes 100% of its parent’s container.
After the element is positioned absolutely and removed from the document flow, it takes a min eidth which is defined by the browser. If the content is larger than this width the it will take the required place to display its content.
So we have to specify the width of the absolutely positioned element manually.
Oh wow.
Cool, thanks a lot!