div大小变化问题
<script type="text/javascript">var width=document.body.clientWidth;
var height=document.body.clientHeight;
//alert(width);
document.getElementById("data").style.width=width-260+"px";
document.getElementById("data").style.height=height-140+"px";
document.getElementById("content").style.width=width-260+"px";
var mydiv=document.getElementById("data");
var mydiv_resize=function(){
mydiv.style.width=document.body.clientWidth-260+"px";
mydiv.style.height=document.body.clientHeight-140+"px";
}
mydiv_resize();
window.onresize=mydiv_resize;
</script>可是窗口变化时div没有变化,请教
<div id="data" style=" border:red 2px solid;">dsafksadk</div>
<p></p>
<div id="content" style=" border:red 2px solid;">xxxxxxxxxxx</div>
</body>
</html>
<script type="text/javascript">
[color=#0000FF]var[/color] width = document.body.clientWidth;
[color=#0000FF]var[/color] height = document.body.clientHeight;
document.getElementById("data").style.width = width - 260 + "px";
document.getElementById("data").style.height = height - 140 + "px";
document.getElementById("content").style.width = width - 260 + "px";
[color=#0000FF]var[/color] mydiv = document.getElementById("data");
[color=#0000FF]var[/color] mydiv_resize = [color=#0000FF]function[/color]() {
mydiv.style.width = document.body.clientWidth - 260 + "px";
mydiv.style.height = document.body.clientHeight - 140 + "px";
}
mydiv_resize();
window.onresize = mydiv_resize;
</script>[/code]
有反应 IE浏览器有反应 [quote][b]以下是引用[u]gameohyes[/u]在2010-8-25 22:12:09的发言:[/b]
IE浏览器有反应[/quote]FF同样有反应
页:
[1]