根据 css 中的其他元素更改 div 滚动高度

change div scroll height based on other elements in css

我有一个 div 元素将项目包装在其中

<div id="#wrapper" style="overflow: scroll; max-height: 100%;">
  <ul> 
    <!--lots of li's go here.
      When an li is clicked, "#details" pop from below.
    -->
  </ul>
</div>

<div id="#detils" style="display:none; height:30%;">item details</div>

由于可能有很多项目,div 有:

max-height: 100%;

单击项目时,详细信息部分应从下方弹出。 它的高度是 30%.

如何让 div 包装滚动条高度自动适应 CSS 只有 的新情况。换句话说:它的高度现在应该变成 100%-70%=30%

您可以添加一个 class,当点击该项目时它有 height:30;

希望this能帮到你