侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 128898 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

jQuery监听浏览器窗口大小的变化

2024-04-28 星期日 / 0 评论 / 0 点赞 / 2 阅读 / 930 字

方法一:在标签上加入 onLoad="" onResize="" 方法 写上对应的方法即可方法二:window.onresize=function(){///.....} 在方法里面写上对应的代

方法一:在标签上加入  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>  

 

广告 广告

评论区