关于浮动div居中的问题!急.....

我并不知道DIV浮动层的宽度,高度,如何使浮动层在任何分辩率的情况下居中!
---------------------------------------------------------------

 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<title> * emu * </title>
 5<script>   
 6<!--   
 7window.onresize = resetDIV;   
 8function resetDIV()   
 9{   
10with(document.getElementsByTagName("DIV")[0].style)   
11{   
12left = (document.body.offsetWidth-parseInt(width))/2   
13top = (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>

这个可以根据页面的变化动态改变层的位置。

Published At
Categories with Web编程
comments powered by Disqus