DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery常見問題 >> Jquery實現遮罩層,彈出DIV周圍都灰色不能操作
Jquery實現遮罩層,彈出DIV周圍都灰色不能操作
編輯:JQuery常見問題     
Jquery實現遮罩層,就是彈出DIV周圍都灰色不能操作,兼容各種浏覽器。

效果預覽:http:///keleyi/phtml/div/index.htm

完整代碼:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery遮罩層</title>

<style type="text/css">
body{margin:0px;}
#BgDiv{background-color:#e3e3e3; position:absolute; z-index:99; left:0; top:0; display:none; width:100%; height:1000px;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}

#DialogDiv{position:absolute;width:400px; left:50%; top:50%; margin-left:-200px; height:auto; z-index:100;background-color:#fff; border:1px #8FA4F5 solid; padding:1px;}
#DialogDiv h2{ height:25px; font-size:14px; background-color:#8FA4F5; position:relative; padding-left:10px; line-height:25px;}
#DialogDiv h2 a{position:absolute; right:5px; font-size:12px; color:#000000}
#DialogDiv .form{padding:10px;}

#DialogDiv2{position:absolute;width:400px; left:50%; top:50%; margin-left:-200px; height:auto; z-index:100;background-color:#fff; border:1px #8FA4F5 solid; padding:1px;}
#DialogDiv2 h2{ height:25px; font-size:14px; background-color:#8FA4F5; position:relative; padding-left:10px; line-height:25px;}
#DialogDiv2 h2 a{position:absolute; right:5px; font-size:12px; color:#000000}
#DialogDiv2 .form{padding:10px;}

#DialogDiv3{position:absolute;width:400px; left:50%; top:50%; margin-left:-200px; height:auto; z-index:100;background-color:#fff; border:1px #8FA4F5 solid; padding:1px;}
#DialogDiv3 h2{ height:25px; font-size:14px; background-color:#8FA4F5; position:relative; padding-left:10px; line-height:25px;}
#DialogDiv3 h2 a{position:absolute; right:5px; font-size:12px; color:#000000}
#DialogDiv3 .form{padding:10px;}
</style>

<script type="text/javascript" src="http:///keleyi/pmedia/jquery-1.9.1.min.js"></script>
<script language="javascript" type="text/javascript">
function ShowDIV(thisObjID) {
$("#BgDiv").css({ display: "block", height: $(document).height() });
var yscroll = document.documentElement.scrollTop;
$("#" + thisObjID).css("top", "100px");
$("#" + thisObjID).css("display", "block");
document.documentElement.scrollTop = 0;
}

function closeDiv(thisObjID) {
$("#BgDiv").css("display", "none");
$("#" + thisObjID).css("display", "none");
}
</script>

</head>

<body>
<div id="BgDiv"></div>

<!--遮罩層顯示的DIV1-->
<div id="DialogDiv" style="display:none">
<h2>彈出層<a href="javascript:;" id="btnClose" onclick="closeDiv('DialogDiv')">關閉</a></h2>
<div class="form">我是彈出對話框111111!!</div>
</div>

<!--遮罩層顯示的DIV2-->
<div id="DialogDiv2" style="display:none">
<h2>彈出層<a href="javascript:;" id="btnClose2" onclick="closeDiv('DialogDiv2')">關閉</a></h2>
<div class="form">我是彈出對話框2222!!</div>
</div>

<!--遮罩層顯示的DIV3-->
<div id="DialogDiv3" style="display:none">
<h2>彈出層<a href="javascript:;" id="btnClose3" onclick="closeDiv('DialogDiv3')">關閉</a></h2>
<div class="form">我是彈出對話框3333333!!</div>
</div>

<p>
<input value="彈出遮罩層1" type="button" id="btnShow1" onclick="ShowDIV('DialogDiv')" />
<input value="彈出遮罩層2" type="button" id="btnShow2" onclick="ShowDIV('DialogDiv2')" />
<input value="彈出遮罩層3" type="button" id="btnShow3" onclick="ShowDIV('DialogDiv3')" />
</p>

<div style="background-color:#959822; width:100%;height:150px;">請滾動鼠標使頁面向下</div>
<div style="background-color:Green; width:100%;height:150px;">www.<a href="http:///dev/94fb5964c80ee829.htm" target="_blank">圖片返回頂部效果</a></div>
<div style="background-color:Red; width:100%;height:150px;">歡迎</div>
<div style="background-color:Yellow; width:100%;height:150px;">hi</div>
<div style="background-color:Silver; width:100%;height:150px;"></div>
<div style="background-color:Aqua; width:100%;height:150px;"></div>
<div style="background-color:Fuchsia; width:100%;height:150px;">keleyi</div>
<div style="background-color:Green; width:100%;height:150px;"></div>
<div style="background-color:Blue; width:100%;height:150px;"></div>
<div style="background-color:Olive; width:100%;height:150px;"> 返回頂部</div>
<div style="background-color:Green; width:100%;height:150px;">A</div>
<div style="background-color:Purple; width:100%;height:150px;">jquery</div>
<div style="background-color:Green; width:100%;height:150px;"><a href="http:///a/bjac/6f008786225269ac.htm" target="_blank">原文</a></div>
<div style="background-color:Lime; width:100%;height:150px;"></div>
<div style="background-color:Orange; width:100%;height:150px;">完整代碼</div>
</body>
</html>

遮罩層集合:http:///a/bjac/516kx8p1.htm
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved