61,112
社区成员
发帖
与我相关
我的任务
分享
function onresize() //函数:获取尺寸
{
var winWidth = 0;
var winHeight = 0;
//获取窗口宽度
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;
winWidth = document.documentElement.clientWidth;
}
//***增加自己的处理
}
因为div大小固定,又上下左右居中,所以可以计算得到div的位置,然后在函数内调整它的位置。