DIV高度等于浏览器高度,内容超过后出滚动条

zhangyulinz 2016-07-04 09:11:26
让一个DIV的高度自动等于页面高度,不随里面内容多少改变,当里面的内容超出后,这个DIV出现滚动条,不改变DIV自身的高度,
已经设置了
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

上面一横排DIV,高度不确定
下面一个DIV,里面水平盒子左中右三个DIV,要设置左和右两个DIV高度等于浏览器剩下的高度,并且不能超出,里面的内容超过高度时自动出现滚动条overflow-y: auto; 要怎么设置呢
不知道怎么说了,反正就是没实现,谁有好的方法么
...全文
1938 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangyulinz 2017-03-17
  • 打赏
  • 举报
回复
非常感谢楼上各位
iChos10 2016-07-09
  • 打赏
  • 举报
回复
上面那个IE不太兼容,这个兼容三个浏览器 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>iChos - 后台管理</title> <style type="text/css"> .main { background: #888; position: absolute; left: 0px; top: 0px; bottom: 0px; right: 0px; display: table; height: 100%; width: 100%; } .row { display: table-row; } .top, .bottom { display: table-cell; } .top { background: red; } .bottom { background: blue; height: 100%; } .left, .right, .center { float: left; } .left { height: 100%; background: #eee; width: 200px; } .center { background: #eee; width: 400px; margin-left: 10px; } .right { height: 100%; background: #ccc; width: 300px; margin-left: 10px; } </style> </head> <body style="overflow:hidden"> <div class="main"> <div class="row"> <div class=top>我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上我是上<br>我是上</div> </div> <div class="row"> <div class="bottom"> <div class="left">我是左边</div> <div class="center">我是中间</div> <div class="right">我是右边</div> </div> </div> </div> </body> </html>
iChos10 2016-07-09
  • 打赏
  • 举报
回复
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>iChos - 后台管理</title> <style type="text/css"> .main {background:#888;position:absolute; left:0px;top:0px;bottom:0px;right:0px; display:table;height:100%;width:100%; } .row {display:table-row; } .top, .bottom {display:table-cell } .top { background: red; } .bottom {background:blue;height:100%;position:relative; } .left {position:absolute;top:0px;bottom:0px;left:0px;background:#ddd;width:200px; } .center { position: absolute; top: 0px; bottom: 0px; left:250px; background: #eee; width: 400px; } .right { position: absolute; top: 0px; bottom: 0px; right:0px; background: #ccc; width: 300px; } </style> </head> <body style="overflow:hidden"> <div class="main"> <div class="row"> <div class=top>我是上<br>我是上</div> </div> <div class="row"> <div class="bottom"> <div class="left">我是左边</div> <div class="center">我是中间</div> <div class="right">我是右边</div> </div> </div> </div> </body> </html>
ldxsik 2016-07-09
  • 打赏
  • 举报
回复
html5的写法,已经测试ok
ldxsik 2016-07-08
  • 打赏
  • 举报
回复
配合js,可以实现吧
张祠 2016-07-08
  • 打赏
  • 举报
回复
要给那个div设置一个高度
张祠 2016-07-08
  • 打赏
  • 举报
回复
在需要显示滚动条的div样式中加上overflow-y: auto;
1. HTML对象获取问题 3 2. const问题 3 3. event.x与event.y问题 3 4. window.location.href问题 3 5. frame问题 3 6. 模态和非模态窗口问题 3 7. firefox与IE的父元素(parentElement)的区别 3 8. document.formName.item(”itemName”) 问题 3 9. 集合类对象问题 3 10. 自定义属性问题 3 11. input.type属性问题 3 12. event.srcElement问题 3 13. body载入问题 3 14. 事件委托方法 3 15. Table操作问题 3 16. 对象宽高赋值问题 3 Ø CSS 3 1. cursor:hand VS cursor:pointer 3 2. innerText在IE中能正常工作,但在FireFox中却不行. 3 3. CSS透明 3 4. css中的width和padding 3 5. FF和IE BOX模型解释不一致导致相差2px 3 6. IE5 和IE6的BOX解释不一致 3 7. ul和ol列表缩进问题 3 8. 元素水平居中问题 3 9. Div的垂直居中问题 3 10. margin加倍的问题 3 11. IE与宽度和高度的问题 3 12. 页面的最小宽度 3 13. DIV浮动IE文本产生3象素的bug 3 14. IE捉迷藏的问题 3 15. float的div闭合;清除浮动;自适应高度 3 16. 高度不适应 3 17. IE6下图片下有空隙产生 3 18. 对齐文本与文本输入框 3 19. LI中内容超过长度后以省略号显示 3 20. 为什么web标准中IE无法设置滚动条颜色了 3 21. 为什么无法定义1px左右高度的容器 3 22. 链接(a标签)的边框与背景 3 23. 超链接访问过后hover样式就不出现的问题 3 24. FORM标签 3 25. 属性选择器(这个不能算是兼容,是隐藏css的一个bug) 3 26. 为什么FF下文本无法撑开容器的高度 3

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧