js實現(xiàn)在頁面上彈出蒙板技巧簡單實用
更新時間:2013年04月16日 17:46:03 作者:
蒙板是兩個div,其中popWindow樣式的div用于遮住整個頁面并半透明,感興趣的朋友可以參考下哈,希望對你學(xué)習(xí)js蒙版有所幫助
蒙板是兩個div,其中popWindow樣式的div用于遮住整個頁面,并半透明。maskLayer 在popWindow上面,用于顯示蒙板的信息,比如“載入中……“
<html>
<head>
<style type="text/css">
.popWindow {
background-color:#9D9D9D;
width: 100%;
height: 100%;
left: 0;
top: 0;
filter: alpha(opacity=50);
opacity: 0.5;
z-index: 1;
position: absolute;
}
.maskLayer {
background-color:#000;
width: 200px;
height: 30px;
line-height: 30px;
left: 50%;
top: 50%;
color:#fff;
z-index: 2;
position: absolute;
text-align:center;
}
</style>
<script language="javascript" type="text/javascript">
function showDiv() {
document.getElementById('popWindow').style.display = 'block';
document.getElementById('maskLayer').style.display = 'block';
}
function closeDiv() {
document.getElementById('popWindow').style.display = 'none';
document.getElementById('maskLayer').style.display = 'none';
}
</script>
</head>
<body>
<div onclick="showDiv()" style="display:block; cursor:pointer">
彈出蒙板
</div>
<div id="popWindow" class="popWindow" style="display: none;">
</div>
<div id="maskLayer" class="maskLayer" style="display: none;">
<a href="#" onclick="closeDiv()" style="cursor:pointer;text-decoration: none;">
關(guān)閉蒙板
</a>
</div>
</body>
</html>
復(fù)制代碼 代碼如下:
<html>
<head>
<style type="text/css">
.popWindow {
background-color:#9D9D9D;
width: 100%;
height: 100%;
left: 0;
top: 0;
filter: alpha(opacity=50);
opacity: 0.5;
z-index: 1;
position: absolute;
}
.maskLayer {
background-color:#000;
width: 200px;
height: 30px;
line-height: 30px;
left: 50%;
top: 50%;
color:#fff;
z-index: 2;
position: absolute;
text-align:center;
}
</style>
<script language="javascript" type="text/javascript">
function showDiv() {
document.getElementById('popWindow').style.display = 'block';
document.getElementById('maskLayer').style.display = 'block';
}
function closeDiv() {
document.getElementById('popWindow').style.display = 'none';
document.getElementById('maskLayer').style.display = 'none';
}
</script>
</head>
<body>
<div onclick="showDiv()" style="display:block; cursor:pointer">
彈出蒙板
</div>
<div id="popWindow" class="popWindow" style="display: none;">
</div>
<div id="maskLayer" class="maskLayer" style="display: none;">
<a href="#" onclick="closeDiv()" style="cursor:pointer;text-decoration: none;">
關(guān)閉蒙板
</a>
</div>
</body>
</html>
相關(guān)文章
詳談構(gòu)造函數(shù)加括號與不加括號的區(qū)別
下面小編就為大家?guī)硪黄斦剺?gòu)造函數(shù)加括號與不加括號的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10
深入理解JavaScript中為什么string可以擁有方法
下面小編就為大家?guī)硪黄钊肜斫釰avaScript中為什么string可以擁有方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
對google個性主頁的拖拽效果的js的完整注釋[轉(zhuǎn)]
對google個性主頁的拖拽效果的js的完整注釋[轉(zhuǎn)]...2007-04-04
深入理解JavaScript字節(jié)二進制知識以及相關(guān)API
當前,前端對二進制數(shù)據(jù)有許多的API可以使用,這豐富了前端對文件數(shù)據(jù)的處理能力,有了這些能力,就能夠?qū)D片等文件的數(shù)據(jù)進行各種處理。本文將著重介紹一些前端二進制數(shù)據(jù)處理相關(guān)的API知識,希望對大家有所幫助2023-02-02
JS通過識別id、value值對checkbox設(shè)置選中狀態(tài)
最開始需要獲取的是input value值設(shè)置checkbox選中狀態(tài),由于input value要使用計算業(yè)務(wù),后來改造為id,這里就為大家分享一下實現(xiàn)代碼,需要的朋友可以參考下2020-02-02

