How can the parent div be highly adaptive and use position positioning to avoid collapse?

as shown in figure

the parent div is position:relative,4, and the child div is absolute,. When the parent height is auto, how to use the child div height to prop up the parent div?

.

Mar.13,2021

absolute are separated from the document stream, and


can only be achieved by JS


you try to give the parent div setting: overflow:hidden;
verification, reply me if you can.


then you can use js to get this height in a div, in the parent div, and then set a box-sizing:border-box;


out of the document stream to the parent div. It doesn't work if the parent writes auto .

Menu