【发布时间】:2014-11-11 14:10:58
【问题描述】:
我想在底部子 div 溢出父级时添加滚动。我不想为顶部和底部 div 设置任何高度。它必须计算父级的剩余高度,并且它应该只在底部 div 中显示滚动
#parent{
height:100px;
width:100px;
border: 1px solid red;
}
#top{
background-color: #CCC;
width:100%;
height:auto
}
#bottom{
height: auto;
width: 100%;
background-color: grey;
overflow-y:auto;
}
<div id="parent">
<div id="top">
top content
no need of scroll
</div>
<div id="bottom">
I need scroll here when
this content overflow the parent.
</div>
</div>
【问题讨论】: