我正在尝试制作一个div,它在具有height: auto and max-height:(heightpx);
设置的div内滚动其内容。 我注意到,如果将高度设置为一个值并删除max-height,则可以正常工作。
<div style="height:auto; max-height:200px; background:red;">
<div class="fill">
<div class="fill">
<div class="fill">
<div class="scrolly" style="height: calc(100% - 45px)">
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
</div>
</div>
</div>
</div>
.scrolly {
overflow-x: hidden;
overflow-y: scroll;
position: relative;
}
.fill {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
这里有一个 jsfiddle http://jsfiddle.net/szze6a66/
。