代码
css部分
.parent{
position:relative;
height:100%;//高度根据需求自行设定
}
.child{
position:absolute;
left:0;
top:0;
right:0;
bottom:0; //left,top,right,bottom都为0,充满真个页面
overflow-y:auto;
overflow-x:hidden; //设置Y轴出现滚动条,X轴隐藏
}
html部分
<div class="parent">
<div class="child"></div>
</div>
当child中内容过多溢出是时,child就会出现滚动条,不需要设定固定的高度,和使用js自动计算