如何使div在任何分辩率的情况下居中

<html>   
<head>   
<meta  http-equiv="Content-Type"  content="text/html;  charset=gb2312">   
<title>  *  emu  *  </title>   
<SCRIPT>   
<!--   
window.onresize  =  resetDIV;   
function  resetDIV()   
           {   
           with(document.getElementsByTagName("DIV")[0].style)   
                       {   
                       left  =  (document.body.offsetWidth-parseInt(width))/2   
                       top  =  (document.body.offsetHeight-parseInt(height))/2   
                       }   
           }   
//-->   
</SCRIPT>   
</head>   
<body  onload="resetDIV()">   
<div  style="position:absolute;width=200;height=200;background-color=yellow"></div>   
</body>   
</html>  

你可能感兴趣的:(如何使div在任何分辩率的情况下居中)