Home >Web Front-end >CSS Tutorial >How to Make a Parent Div Expand to Accommodate an Absolutely Positioned Child?
In a situation where a nested child element (child2) must appear below its sibling (child1) in mobile view, sometimes it becomes necessary to position child2 absolutely. However, doing so often leads to a problem: absolute elements are removed from the flow, causing the parent div to ignore their height.
As mentioned in the initial question:
"I know that absolute positioned elements are removed from the flow, thus ignored by other elements."
This means that setting the parent div's height according to the absolute-positioned child element is not possible. So, what options are left?
The above is the detailed content of How to Make a Parent Div Expand to Accommodate an Absolutely Positioned Child?. For more information, please follow other related articles on the PHP Chinese website!