您的位置:首页 > 其它

设置DIV显示在屏幕中间

2010-07-12 18:15 288 查看
/*设置客户端的高和宽*/
function getClientBounds(){
var clientWidth;
var clientHeight;

clientWidth = document.compatMode == "CSS1Compat" ?
document.documentElement.clientWidth : document.body.clientWidth;
clientHeight = document.compatMode == "CSS1Compat" ?
document.documentElement.clientHeight : document.body.clientHeight;

return {width: clientWidth, height: clientHeight};
}


/*设置客户端的高和宽*/
function divcenter(){
var divId=document.getElementById('mxh');
var rr=new getClientBounds();
divId.style.display='block';
divId.style.left=(rr.width-divId.clientWidth)/2+document.body.scrollLeft;
divId.style.top=(rr.height-divId.clientHeight)/2+document.body.scrollTop;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: