css 中div不用设定高度,自动根据内容出现滚动条

来源:互联网 发布:一楼土木人淘宝店没了 编辑:程序博客网 时间:2024/05/21 08:42

css 中div不用设定高度,自动根据内容出现滚动条

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自动计算
阅读全文
0 0
原创粉丝点击