怎么判断 当div里面的内容 超出浏览器的可视区域 div出现滚动条

outluo 2014-01-07 02:27:50
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{
margin:0;
padding:0;
}

.div{
width:100%;
height:400px;
background:#069;
float:left;
}
.div1{
width:100%;
background:#CCC;
}

</style>
<script>

</script>
</head>

<body>
<div class="div">

</div>
<div class="div1">
<p>1111111111111</p>
</div>
</body>

</html>
当class="div1"的div 里面的内容超出 浏览器的底部的时候 div出现滚动条而不是浏览器出现滚动条
...全文
1256 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
打字员 2014-01-07
  • 打赏
  • 举报
回复
不知道你的具體需求,只能猜一下,希望對你有幫助

<!DOCTYPE HTML>
<head>
<meta charset="GBK" >
<title>title</title>
<style type="text/css">
*{padding:0;margin:0;}
html,body{height:100%;}
.header{width:100%;height:100px;position:absolute;left:0;top:0;z-index:3;background:#0f0;}
.sidebar{width:120px;height:100%;position:absolute;left:0;top:0;z-index:2;background:#f00;}
.sidebar .inner{padding-top:100px;}
.bodyer{width:100%;height:100%;overflow:hidden;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;padding:100px 0 0 120px;position:absolute;left:0;top:0;z-index:1;background:#0ff;}
.bodyer .inner{width:100%;height:100%;overflow:auto;}
</style>
</head>
<body>
<div class="header">
	header
</div>
<div class="sidebar">
	<div class="inner">sidebar</div>
</div>
<div class="bodyer">
	<div class="inner">
		<div style="width:200px;height:1200px;">content</div>
	</div>
</div>
</body>
</html>
allali 2014-01-07
  • 打赏
  • 举报
回复
没有设定高度滚动条是不会出来的,不知道你要做什么效果。
outluo 2014-01-07
  • 打赏
  • 举报
回复
引用 2 楼 Lyble 的回复:
给class="div1"的div设置一个高度,然后:overflow-y: auto;
不设置宽度能不能判断div 里面的内容超出 浏览器的底部的时候 div出现滚动条而不是浏览器出现滚动条
outluo 2014-01-07
  • 打赏
  • 举报
回复
引用 1 楼 zzgzzg00 的回复:
设置height后设置overflow试试
不设置宽度能不能判断div 里面的内容超出 浏览器的底部的时候 div出现滚动条而不是浏览器出现滚动条
義東 2014-01-07
  • 打赏
  • 举报
回复
给class="div1"的div设置一个高度,然后:overflow-y: auto;
似梦飞花 2014-01-07
  • 打赏
  • 举报
回复
设置height后设置overflow试试

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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