相关疑难解决方法(0)

父级的 maxHeight 和溢出-y:滚动其子级之一

可以maxHeight在父级上设置并让一个特定的孩子 (1) 占用尽可能多的空间并且 (2) 已经overflow-y: scroll在那个孩子上设置了吗?

<div style="max-height: 200px">
  <div>Header that I don't want to specify any height on</div>
  <div style="max-height: auto; overflow-y: scroll">
    <div>Item no 1 in long list>
    <div>Item no 2 in long list>
    ...
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

上面的代码并max-height: auto不起作用。我最接近的是只有一个孩子并将其设置max-heightinherit这样:

<div style="max-height: 200px">
  <div style="max-height: inherit; overflow-y: scroll">
    <div>Item no 1 in long list>
    <div>Item no 2 in long list>
    ...
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

哪个有效,但如果我有 2 个孩子并且max-height: …

css

2
推荐指数
1
解决办法
3338
查看次数

标签 统计

css ×1