我有一个评论列表,其中包含绝对定位的div中的内容。这是设计的一部分。它们位于弹出框中,该框设置为显示:无,然后使用单击事件淡入。找到绝对定位的子元素的高度并将其高度设置为其父亲
我遇到的问题是我需要获取内部绝对内容的高度并将该高度设置为其父级,并且似乎无法使其工作。每个项目可以是任意长度,因为它们是评论。
我在这里做了一个小提琴来展示我有什么样的结构。 http://jsfiddle.net/ZTDyA/
这是结构
<div class="hidden">
<ul class="list">
<li>
<div class="inner">there is some content here</div>
<div class="base">This is a div under the .inner div</div>
</li>
<li>
<div class="inner">For the thing I have made this has to be positioned absolutely, but the content could be of any length so I need the parent to each of these inners to be set to the height of the inner div.</div>
<div class="base">This is a div under the .inner div</div>
</li>
</ul>
</div>
为什么你就不能删除'位置? http://jsfiddle.net/dfsq/ZTDyA/2/ – dfsq 2013-02-22 13:33:32
由于设计原因,评论必须位于悬停时可见的另一图层之上。 – 2013-02-22 13:34:59