jQuery监听浏览器窗口大小的变化实例
方法一:在标签上加入 onLoad=""onResize="" 方法 写上对应的方法即可
方法二:window.onresize=function(){///.....}在方法里面写上对应的代码即可
着两种方法基本都可以解决问题。
<script>
functionadjust(obj){
vardiv=document.getElementById("pad");
vartxt=document.getElementById("txt");
varw=document.body.clientWidth;
varh=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>
<bodystyle="margin:0px;height:0px;">
<divid="pad"style="background:red;zoom:1;margin:0px;height:0px;">
<inputtype="text"id="txt">
</div>
</body>
以上这篇jQuery监听浏览器窗口大小的变化实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下