<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm9.aspx.vb" Inherits="WebTest.WebForm9" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="Content/aa.css" rel="stylesheet" />
<script type="text/javascript" src="scripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function () {
$(".showbtn").click(function () {
$("#bg").css({
display: "block", height: $(document).height()
});
var $box = $('.box');
$box.css({
//设置弹出层距离左边的位置
left: ($("body").width() - $box.width()) / 2 - 20 + "px",
//设置弹出层距离上面的位置
top: ($(window).height() - $box.height()) / 2 + $(window).scrollTop() + "px",
display: "block"
});
});
//点击关闭按钮的时候,遮罩层关闭
$(".close").click(function () {
$("#bg,.box").css("display", "none");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<p class="showbtn"><a href="javascript:void(0);">显示遮罩层</a></p>
<div id="bg"></div>
<div class="box" style="display: none">
<h2>jQuery 学习交流<a href="#" class="close">关闭</a></h2>
<div class="list">
<ul>
<li>aaaaa</li>
<li>bbbbb</li>
<li>ccccc</li>
</ul>
</div>
</div>
</form>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="Content/aa.css" rel="stylesheet" />
<script type="text/javascript" src="scripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function () {
$(".showbtn").click(function () {
$("#bg").css({
display: "block", height: $(document).height()
});
var $box = $('.box');
$box.css({
//设置弹出层距离左边的位置
left: ($("body").width() - $box.width()) / 2 - 20 + "px",
//设置弹出层距离上面的位置
top: ($(window).height() - $box.height()) / 2 + $(window).scrollTop() + "px",
display: "block"
});
});
//点击关闭按钮的时候,遮罩层关闭
$(".close").click(function () {
$("#bg,.box").css("display", "none");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<p class="showbtn"><a href="javascript:void(0);">显示遮罩层</a></p>
<div id="bg"></div>
<div class="box" style="display: none">
<h2>jQuery 学习交流<a href="#" class="close">关闭</a></h2>
<div class="list">
<ul>
<li>aaaaa</li>
<li>bbbbb</li>
<li>ccccc</li>
</ul>
</div>
</div>
</form>
</body>
</html>