DIV层浮动在页面的前面,并且无法点击DIV层后面

来源:百度知道 编辑:UC知道 时间:2024/09/24 06:30:10
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>at center</title>
</head>
<script>
function floatdiv()
{
document.getElementById("mydiv").style.left=(document.body.offsetWidth-document.getElementById("mydiv").offsetWidth)/2+document.body.scrollLeft;
document.getElementById("mydiv").style.top=(document.body.clientHeight-document.getElementById("mydiv").offsetHeight)/2+document.body.scrollTop;
}
window.onload=floatdiv;
window.onscroll=floatdiv;
</script>
<body>
<div id=mydiv style="position:absolute;width:400px;height:200px;background:lightgreen;border:1px solid yellow;line-height:200px;vertical-align:middle;text-align:center">中间浮动页面</div>
<p>网页内容</p>
</body>
</html>

---------------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>at center</title>
</head>
<script>
function floatdiv()
{
document.getElementById("mydiv").style.left=(document.body.offsetWidth-document.getElementById("mydiv").offsetWidth)/2+document.body.scrollLeft;
document.getElementById("mydiv").style.top=(document.body.clientHeight-document.getElementById("mydiv").offsetHeight)/2+document.body.scrollTop;
document.getElementById("mydiv2").style.height=document.body.clientHeight;
document.getElementById("mydiv2").style.width=document.body.offsetWidth;
}
window.onload=floatdiv;
window.onscroll=floatdiv;
</script>
<body>
<div id=mydiv style="position:absolute;width:400px;height:200px;background:lightgreen;border:1px solid yellow;line