使浮动DIV始终居中

 

  1. <html>  
  2.     <head>  
  3.     <meta  http-equiv="Content-Type"  content="text/html;  charset=gb2312">  
  4.     <title>  *  emu  *  </title>  
  5.     <SCRIPT>  
  6.     <!--  
  7.         window.onresize  =  resetDIV;  
  8.         function  resetDIV()  
  9.         {  
  10.             with(document.getElementsByTagName("DIV")[0].style)  
  11.             {  
  12.                 left  =  (document.body.offsetWidth-parseInt(width))/2  
  13.                 top  =  (document.body.offsetHeight-parseInt(height))/2  
  14.              }  
  15.         }  
  16.     //-->  
  17.     </SCRIPT>  
  18.     </head>  
  19.     <body  onload="resetDIV()">  
  20.         <div  style="position:absolute;width=200;height=200;background-color=yellow"></div>  
  21.     </body>  
  22. </html>  

你可能感兴趣的:(div)