js实现div动态改变大小
来源:互联网 发布:vb.net excel另存为 编辑:程序博客网 时间:2024/05/20 13:15
网上看到的相关代码,记下,以备日后使用。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <style type="text/css"> body { margin:0; padding:0; } #header { height: 70px; background-color: Blue; } #middle { height: auto; background-color: Green; } #footer { height: 30px; background-color: Gray; } </style></head><body> <div> <div id="header"> </div> <div id="middle"> </div> <div id="footer"> </div> </div> <script type="text/javascript"> var winWidth = 0; var winHeight = 0; function findDimensions() { //函数:获取尺寸 //获取窗口宽度 if (window.innerWidth) { winWidth = window.innerWidth; } else if ((document.body) && (document.body.clientWidth)) { winWidth = document.body.clientWidth; } //获取窗口高度 if (window.innerHeight) { winHeight = window.innerHeight; } else if ((document.body) && (document.body.clientHeight)) { winHeight = document.body.clientHeight; } //通过深入Document内部对body进行检测,获取窗口大小 if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) { winHeight = document.documentElement.clientHeight-100; winWidth = document.documentElement.clientWidth; } //设置div的具体宽度=窗口的宽度的% if (document.getElementById("middle")) { document.getElementById("middle").style.height = winHeight + "px"; } } findDimensions(); window.onresize = findDimensions; </script></body></html>
0 1
- js实现div动态改变大小
- JS实现拖动div改变大小
- 动态改变DIV大小
- javascript动态改变div大小
- javascript div动态大小改变
- javascript div动态大小改变
- 实现div的大小随着内容进行动态改变
- Js - 可拖动可改变大小div的实现代码
- 流动布局中浏览器大小改变时通过js动态计算和放置相同大小的div块
- js 拖动div 并改变div大小 的搜索网址
- js通过八个点 拖动改变div大小的实现方法
- js通过八个点 拖动改变div大小的实现方法
- js 动态改变div内部布局
- js 如何动态改变div的位置
- JS 动态增加DIV 的大小
- 使用JavaScript实现动态改变控件大小
- 拖动改变Div大小
- 纯js实现Div在页面垂直居中!可根据浏览器大小的改变而改变!兼容各种浏览器----神器版!
- LinearLayout measure过程中的几次遍历分析
- 集合类使用set
- C++ 资源大全
- java工具(二)----poi操作excel和xml,定时任务
- java封装导出excel之——优化
- js实现div动态改变大小
- POJ 1836 Alignment(LIS变形)
- 【C#】装箱与拆箱
- Javascript模块化编程(一):模块的写法
- leetcode292题 题解 翻译 C语言版 Python版
- com.mysql.jdbc.NotUpdatable: Result Set not updatable (references no primary keys).(解决方法)
- 安卓开发——AndroidStudio生成getter,setter,tostring,constructor等函数的方式
- HIVE与mysql
- 【ITOO】---StringBuilder对象