CSS位置:绝对+动态高度 [英] CSS position:absolute + dynamic height
问题描述
我有4 < div>
个标签,所有在 position:absolute
他们使用顶部
和左
。
I have 4 <div>
tags one after the other, all in position:absolute
and I align them using top
and left
.
标签包含动态内容,div的高度根据其中的文本量而更改。然而,当我设置所有div的 top
和 left
时,第4个div受第3个动态div。
The 3rd div tag contains dynamic content and the height of the div changes according to the amount of text in it. However, as I set the top
and left
of all divs, the 4th div is affected by the height of the 3rd dynamic div.
如何解决这个问题?
推荐答案
您可以尝试在父div中包装4个div并绝对定位。然后,您可以允许其中一个子div的位置影响另一个。
You may want to try wrapping the 4 divs in a parent div and absolutely positioning that. Then you can allow the position of one of the children divs to affect another.
您的解决方案意味着无论您尝试影响 top:60px
和 left:180px
阻止其移动到此处以外的位置,因此动态内容div无法重新定位。
The solution you had meant that no matter what you tried to affect the top:60px
and left:180px
stopped it from moving anywhere other than this, so the dynamic content div wasn't able to reposition it.
这篇关于CSS位置:绝对+动态高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!