jQuery监听浏览器窗口大小的变化实例
方法一:在标签上加入 onLoad="" onResize="" 方法 写上对应的方法即可
方法二:window.onresize=function(){///.....} 在方法里面写上对应的代码即可
着两种方法基本都可以解决问题。
<script> function adjust(obj){ var div = document.getElementById("pad"); var txt = document.getElementById("txt"); var w = document.body.clientWidth; var h = document.body.clientHeight; div.style.width = w/3; div.style.height = h/3; txt.style.width = w/6; txt.style.height = h/6; } window.onload=function(){ window.onresize = adjust; adjust(); } </script> <body style="margin:0px;height:0px;"> <div id="pad" style="background:red;zoom:1;margin:0px;height:0px;"> <input type="text" id="txt"> </div> </body>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17