2

I've done a fair bit of reading on this, and haven't seen an answer that I can get to work. Is it possible to make the parent div height adjust to the height of the absolutely positioned list-item ?

For now, I've compensated by adding large amount of margin.. real large.. but that is not the correct solution here.

The html looks like this: Simple..

<div class="home-section products">
  <div id="gallery-container">
    <ul>
      <li class="one"><img src="showcase-five.jpg"></li>
      <li class="two"><img src="showcase-four.jpg"></li>
      <li class="three"><img src="showcase-one.jpg"></li>
      <li class="four"><img src="showcase-three.jpg"></li>
      <li class="five"><img src="showcase-two.jpg"></li>
    </ul> 
  </div>
</div>

I need the li height to make the .home-section adapt to its height.

If posting a link to the development site is allowed, I'd be happy to share it and allow you to inspect the code in question.

Thanks

4

1 回答 1

5

简而言之,没有。

绝对定位项在标准文档流之外,不会影响任何父元素的高度,也不会改变任何兄弟元素的位置。

如果您需要保留<li>'s ,理论上您可以使用 Javascriptposition: absolute;

于 2013-09-12T02:05:26.227 回答