我有一個評論列表,其中包含絕對定位的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