<script type="text/javascript">
window.onload = function modify() {
var s = document.documentElement.clientHeight;
document.getElementById("div1").style.height =s +"px";
}
window.onresize = modify;
</script>
我用这句代码获取窗口高度,然后让div的高度等于窗口高度,为什么会有滚动条,是不是还应该减去啥什么
<div id="div1">
<div id="div2" style="background-color:red;height:50%"></div>
<div style="background-color:blue;height:50%"></div>
</div>
body{margin:0px;padding:0px;}加这个试试,或者直接不显示div的滚动条
http://www.cnblogs.com/prolifes/articles/1538182.html