原生js實(shí)現(xiàn)半透明遮罩層效果具體代碼
更新時(shí)間:2013年06月06日 16:49:13 作者:
半透明遮罩層效果基本上都是使用插件實(shí)現(xiàn)的,下面為大家分享下使用原生js實(shí)現(xiàn)半透明遮罩效果,感興趣的朋友可以參考下哈,希望對(duì)你熟悉原生js有所幫助
復(fù)制代碼 代碼如下:
<!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>彈出提示</title>
<style>
* {
margin: 0;
padding: 0;
font-size: 12px;
}
html, body {
height: 100%;
width: 100%;
}
#content {
background: #FFFFFF;
padding: 30px;
height: 100%;
}
#content a {
font-size: 30px;
color: #369;
font-weight: 700;
}
#alert { z-index:2;
border: 1px solid #369;
width: 300px;
height: 150px;
background: #e2ecf5;
z-index: 1000;
position: absolute;
display: none;
}
#alert h4 {
height: 20px;
background: #369;
color: #fff;
padding: 5px 0 0 5px;
}
#alert h4 span {
float: left;
}
#alert h4 span#close {
margin-left: 210px;
font-weight: 500;
cursor: pointer;
}
#alert p {
padding: 12px 0 0 30px;
}
#alert p input {
width: 120px;
margin-left: 20px;
}
#alert p input.myinp {
border: 1px solid #ccc;
height: 16px;
}
#alert p input.sub {
width: 60px;
margin-left: 30px;
}
#mask{ position:absolute; top:0; left:0; height:100%; width:100%; background:#000; opacity:0.3; display:none; z-index:1;}
</style>
</head>
<body>
<div id="content"> <a href="#">注冊(cè)</a> </div>
<div id="alert">
<h4><span>現(xiàn)在注冊(cè)</span><span id="close">關(guān)閉</span></h4>
<p>
<label> 用戶名</label>
<input type="text" class="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" />
</p>
<p>
<label> 密 碼</label>
<input type="password" class="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" />
</p>
<p>
<input type="submit" value="注冊(cè)" class="sub" />
<input type="reset" value="重置" class="sub" />
</p>
</div>
<div id="mask"></div><!-- 遮罩層div-->
<script type="text/javascript">
var myAlert = document.getElementById("alert");
var myMask=document.getElementById('mask');
var reg = document.getElementById("content").getElementsByTagName("a")[0];
var mClose = document.getElementById("close");
reg.onclick = function()
{
myMask.style.display="block";
myAlert.style.display = "block";
myAlert.style.position = "absolute";
myAlert.style.top = "50%";
myAlert.style.left = "50%";
myAlert.style.marginTop = "-75px";
myAlert.style.marginLeft = "-150px";
document.body.style.overflow = "hidden";
}
mClose.onclick = function()
{
myAlert.style.display = "none";
myMask.style.display = "none";
}
</script>
</body>
</html>
您可能感興趣的文章:
- js+html5實(shí)現(xiàn)半透明遮罩層彈框效果
- js點(diǎn)擊按鈕實(shí)現(xiàn)帶遮罩層的彈出視頻效果
- js鼠標(biāo)懸浮出現(xiàn)遮罩層的方法
- js實(shí)現(xiàn)遮罩層彈出框的方法
- js css 實(shí)現(xiàn)遮罩層覆蓋其他頁面元素附圖
- 純js實(shí)現(xiàn)遮罩層效果原理分析
- js彈出div并顯示遮罩層
- JS實(shí)現(xiàn)遮罩層效果的簡(jiǎn)單實(shí)例
- JS遮罩層效果 兼容ie firefox jQuery遮罩層
- javascript實(shí)現(xiàn)遮罩層動(dòng)態(tài)效果實(shí)例
相關(guān)文章

firefox下javascript實(shí)現(xiàn)高亮關(guān)鍵詞的方法
“點(diǎn)睛”的廣告代碼,很牛B,本想從中找出在FireFox下如何實(shí)現(xiàn)findText及pasteHTML類似效果的,我看了大半天,楞是沒有看出個(gè)所以然來!還是自己慢慢研究吧。
2007-07-07 
一個(gè)友好的.改善的 Object.prototype.toString的實(shí)現(xiàn)
一個(gè)友好的.改善的 Object.prototype.toString的實(shí)現(xiàn)...
2007-04-04 
JS+HTML5 FileReader對(duì)象用法示例
這篇文章主要介紹了JS+HTML5 FileReader對(duì)象用法,結(jié)合具體實(shí)例形式分析了FileReader對(duì)象的常用方法及簡(jiǎn)單使用技巧,需要的朋友可以參考下
2017-04-04 
JavaScript代碼異常監(jiān)控實(shí)現(xiàn)過程詳解
這篇文章主要介紹了JavaScript代碼異常監(jiān)控實(shí)現(xiàn)過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
2020-02-02 
理解javascript中的Function.prototype.bind的方法
這篇文章主要介紹了理解javascript中的Function.prototype.bind的方法,具有一定參考價(jià)值,有興趣的可以了解一下。
2017-02-02 
JS實(shí)現(xiàn)使用POST方式發(fā)送請(qǐng)求
這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)使用POST方式發(fā)送請(qǐng)求,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
2019-08-08 
Javascript寫了一個(gè)清除“l(fā)ogo1_.exe”的殺毒工具(可掃描目錄)
Javascript寫了一個(gè)清除“l(fā)ogo1_.exe”的殺毒工具(可掃描目錄)...
2007-02-02