读书人

将DIV展示在屏幕中间

发布时间: 2012-10-30 16:13:36 作者: rapoo

将DIV显示在屏幕中间

/*设置客户端的高和宽*/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;     }  
?

读书人网 >编程

热点推荐