CSS - position: absolute; - auto height

后端 未结 8 2032
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 16:46

I am having a problem with some div\'s

The outer div has a min-height, but the inner divs are all varying heights. Because the inner divs are absol

8条回答
  •  有刺的猬
    2020-12-15 17:35

    As far as I know, there's no way for absolutely positioned child elements to affect the height of their statically, or relatively positioned parent elements using only CSS. Either:

    • Reorganize so that the child elements remain in the document flow
    • Use JavaScript on load of the page to set the height of the parent to the height of the largest child

    This issue is common in fade-in/fade-out JavaScript slideshows, and from what I've seen either 1) the height of the parent container needs to be defined or 2) the parent container's height is set dynamically for each slide.

提交回复
热议问题