<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="js/jquery-1.4.2.js" type="text/javascript"></script>
<style type="text/css">
div.window div.title
{
background: #88b8ea;
padding: 0px 8px;
position: relative;
}
div.window div.content
{
clear: both;
height: 200px;
padding: 0px 5px;
overflow: auto;
border: 3px solid #88b8ea;
}
div.window
{
position:absolute;
margin-bottom: 5px;
z-index:1000;
width: 300px;
display:none;
}
div.title img
{
position: absolute;
top: 2px;
right: 2px;
cursor: pointer;
}
</style>
<script type="text/javascript">
$(function() {
$("img").click(function() {
$(this).parent().parent().fadeOut();
$("#doing").fadeOut();
});
});
$(function() {
$("#btncenter").click(function() {
var left = ($(window).width() - $("#center").width()) / 2;
var top = ($(window).height() - $("#center").height()) / 2; //$(window).height() 可视区域的高度
var scrollLeft = $(window).scrollLeft();
var scrollTop = $(window).scrollTop();
$("#center").css("left", left + scrollLeft).css("top", top + scrollTop).fadeIn();
$("#doing").width($(document).width()).height($(document).height()).fadeIn(); //$(document).width()整个文档的高度
});
$(window).scroll(function() {
var left = ($(window).width() - $("#center").width()) / 2;
var top = ($(window).height() - $("#center").height()) / 2;
var scrollLeft = $(window).scrollLeft();
var scrollTop = $(window).scrollTop();
$("#center").css("left", left + scrollLeft).css("top", top + scrollTop);
});
});
</script>
</head>
<body>
<br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br />
<!----遮罩层--->
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#999;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;">
</div>
<!------------>
<div class="window" id="center">
<div class="title">
中间窗口的标题栏
<img src="images/close.gif" /></div>
<div class="content">
中间窗口的内容区 中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区 中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
中间窗口的内容区中间窗口的内容区
</div>
</div>
<input type="button" value="中间" id="btncenter"/>
</body>
</html>