javascript實現(xiàn)的登陸遮罩效果匯總
更新時間:2015年11月09日 08:57:41 投稿:hebedich
小編給大家推薦幾款使用Javascript實現(xiàn)的遮罩效果登陸框,其實這種效果是很常見的,在許多互動的社區(qū)及其它的一些地方,彈出框應用想當流行,在不妨礙網(wǎng)頁運行的情況下,用戶可以輸入登錄信息,實現(xiàn)完美登錄。
javascript實現(xiàn)的登陸遮罩效果
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>遮罩</title> <style> #blanks{ display:none; width:100%; //height:100%; height:100px; position:absolute; top:0; background-color:#ccc; z-index:1000; -moz-opacity: 0.7; opacity:.70; filter: alpha(opacity=70); } #login{ padding:18px; display:none; background-color:pink; width:300px; height:100px; position:absolute; left:400px; top:20%; z-index:1001; } </style> </head> <body onload="setHeight()"> <div id="content"> <input type="button" value="登陸" onclick="showLogin()"> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非常快。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非常快。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非常快。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非??臁T谥蟮挠螒蛑?,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非???。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非常快。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非常快。在之后的游戲中,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> <p>《人生》前15年左右都是些教學關卡,弱弱的,你還沒法點“跳過”。 作為一個初來乍到的新手,你有大把的時間和用不完的精力,但幾乎毫無經(jīng)驗。你會發(fā)現(xiàn)游戲的大多數(shù)元素, 像什么牛逼的工作啦,財富啦,伴侶啦都還沒有解鎖,一直到你真正擁有了它們。 這段時間,你的技能升級得非??臁T谥蟮挠螒蛑?,你再也不可能像這個階段一樣時間充裕而且精力充沛。 如果想要玩出水平,最重要的是要把時間安排得盡可能合理。你的任何一個行動都會改變你的狀態(tài)和技能 </p> </div> <div id="blanks"></div> <div id="login"> <form method="post"> 用戶名:<input type="text" name="username" ><br/> 密 碼:<input type="password" name="password"><br/> <input type="submit" value="提交"> </form> <div id="btnclose" style="position:absolute;left:93%;top:0%;z-index:5;"> <img src="close.png" onclick="hidediv();"/> </div> </div> </body> </html> <script type="text/javascript"> function setHeight() { var h=document.documentElement.scrollHeight; document.getElementById("blanks").style.height=h+"px"; } function hidediv() { document.getElementById("login").style.display="none"; document.getElementById("blanks").style.display="none"; } function showLogin() { document.getElementById("login").style.display="block"; document.getElementById("blanks").style.display="block"; } </script>
上面代碼的核心內容為
<script type="text/javascript"> function setHeight() { var h=document.documentElement.scrollHeight; document.getElementById("blanks").style.height=h+"px"; } function hidediv() { document.getElementById("login").style.display="none"; document.getElementById("blanks").style.display="none"; } function showLogin() { document.getElementById("login").style.display="block"; document.getElementById("blanks").style.display="block"; } </script>
例子二:
<!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 type="text/javascript"> function showLogin() { var loginDiv = document.getElementById("loginDiv"); var zhezhao = document.getElementById("zhezhao"); var clientx = document.documentElement.clientWidth; var clienty = document.documentElement.clientHeight; var l_margin = (clientx - parseInt(loginDiv.style.width)) / 2; var t_margin = (clienty - parseInt(loginDiv.style.height)-200) / 2 loginDiv.style.left = l_margin + "px"; loginDiv.style.top = t_margin +"px"; loginDiv.style.display = "block"; zhezhao.style.display = "block"; } function hidLogin() { var loginDiv = document.getElementById("loginDiv"); var zhezhao = document.getElementById("zhezhao"); loginDiv.style.display = "none"; zhezhao.style.display = "none"; } function titleMove() { var moveable = true; var loginDiv = document.getElementById("loginDiv"); //以下變量提前設置好 var clientX = window.event.clientX; var clientY = window.event.clientY; var moveTop = parseInt(loginDiv.style.top); var moveLeft = parseInt(loginDiv.style.left); document.onmousemove = function MouseMove() { if (moveable) { var y = moveTop + window.event.clientY - clientY; var x = moveLeft + window.event.clientX - clientX; if (x > 0 && y > 0) { loginDiv.style.top = y + "px"; loginDiv.style.left = x + "px"; } } } document.onmouseup = function Mouseup() { moveable = false; } } </script> </head> <body> <!--Main start z-index:0--> <div id="Main" style="position:absolute;z-index:0;"> <a href="javascript:showLogin()">登陸</a> </div> <!--Main start z-index:0--> <!--loginDiv start :z-index:2--> <div id="loginDiv" style="background-color:white;width:300px;height:150px;border:1px solid blue;z-index:2;display:none;position:absolute;border-top:none"> <div onmousedown="titleMove()" id="login_title" style="width:300px;height:25px;background-color:Blue;border:1px solid silver;border-left:none;border-right:none"> <!--<img src="http://www.zhujiangroad.com/images/close.jpg" style="float:right" onclick="hidLogin()"/>--> <a href="javascript:hidLogin()" style="float:right;text-decoration:none;color:white;margin-right:2px;font-size:20px">×</a> </div> <table style="clear:right;width:298px;height:115px;text-align:right;margin-top:10px;"> <tr><td>用戶名:</td><td><input type="text" style="width:180px;" /></td><td> </td></tr> <tr><td>密碼:</td><td><input type="text" style="width:180px;" /></td><td> </td></tr> <tr><td><br /></td><td></td></tr> </table> </div> <!--loginDiv end :z-index:2--> <!--zhezhao start: z-index:1--> <div id="zhezhao" style="position:absolute;z-index:1;width:100%;height:100%;background-color:silver;display:none;opacity:.5;"> <!--zhezhao end--> </div> </body> </html>
例子三:
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>彈出登錄框的實現(xiàn)代碼</title> </head> <body> <style type="text/css"> body { margin: 0px;padding:0 } #div1 { display: none; position: absolute; z-index: 1000; height: 100%; width: 100%; background: #000000; filter:Alpha(opacity=30); } #div2 { display: none; position: absolute; height: 100%; width: 100%; padding-top: 10%; z-index: 1001; left: 0px; top: 0px; } </style> <script> function openme(){ document.getElementById('div1').style.display='block'; document.getElementById('div2').style.display='block'; } function closeme(){ document.getElementById('div1').style.display='none'; document.getElementById('div2').style.display='none'; } function logo_in(){alert() //驗證 //轉向... //myform.action="" //myform.submit() closeme(); } </script> <div id="div1"></div> <div id="div2"> <table width="30%" border="0" cellpadding="3" cellspacing="1" style="background: #ff7300; position:static;filter:progid:DXImageTransform.Microsoft.DropShadow(color=#666666,offX=4,offY=4,positives=true)" align="center"> <tr id="m_tr"> <td><font color="#FFFFFF">歡迎登陸:</font></td> <td align="right"> <input type="button" value="x" onClick="closeme()" style="cursor: hand;"> </td> </tr> <tr> <form name="myform" method="post" > <td colspan="2" width="100%" bgcolor="#FFFFFF" height="150"> username: <input type="text" name="username" size="10"> <br>pasword:<input type="password" name="pasword" size="12"> <br><input type="button" name="logoin" value="登陸" onClick="logo_in()"> <input type="button" name="exit" value="取消" onClick="closeme()"> </td> </form> </tr> </table> </div> <div> <input name="button" type="button" onClick="openme()" value="登陸" /> </div> <br> <div> 簡單的代碼 </div> </body> </html>
例子四
js制作帶有遮罩彈出層實現(xiàn)登錄注冊表單代碼特效
<!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>js制作帶有遮罩彈出層實現(xiàn)登錄注冊表單代碼特效</title> <link rel="stylesheet" type="text/css" href="css/198zone.css"> </head> <body> <a class="btn01" data-toggle="modal" href="#login-modal">登錄</a> <a class="btn02" data-toggle="modal" href="#signup-modal">注冊</a> <a class="btn03" data-toggle="modal" href="#forgetform">找回密碼</a> <a class="btn02" data-toggle="modal" href="#activation-modal">用戶信息</a> <a class="btn03" data-toggle="modal" href="#setpassword-modal">重置密碼</a> <div class="modal" id="login-modal"> <a class="close" data-dismiss="modal">×</a> <h1>登錄</h1> <ul class="login-bind-tp"> <li class="qweibo"> <a href="http://www.dbjr.com.cn"><em> </em> QQ登錄</a> </li> <li class="sina"> <a href="http://www.dbjr.com.cn"><em> </em> 微博登錄</a> </li> <li class="douban"> <a href="http://www.dbjr.com.cn"><em> </em> 豆瓣登錄</a> </li> </ul> <p>或者使用已有帳號登陸:</p> <form class="login-form clearfix" method="post" action="http://www.dbjr.com.cn"> <div class="form-arrow"></div> <input name="email" type="text" placeholder="郵箱:"> <input name="password" type="password" placeholder="密碼:"> <input type="submit" name="type" class="button-blue login" value="登錄"> <input type="hidden" name="return-url" value=""> <div class="clearfix"></div> <label class="remember"><input name="remember" type="checkbox" checked />下次自動登錄 </label> <a class="forgot">忘記密碼?</a> <ul class="third-parties"> <li><p>新浪微博帳號</p></li> <li><p>騰訊微博帳號</p></li> <li><p>豆瓣帳號</p></li> <li><p></p></li> </ul> </form> </div> <div class="modal" id="signup-modal"> <a class="close" data-dismiss="modal">×</a> <h1>注冊</h1> <ul class="login-bind-tp"> <li class="qweibo"> <a href="http://www.dbjr.com.cn"><em> </em> QQ登錄</a> </li> <li class="sina"> <a href="http://www.dbjr.com.cn"><em> </em> 微博登錄</a> </li> <li class="douban"> <a href="http://www.dbjr.com.cn"><em> </em> 豆瓣登錄</a> </li> </ul> <p>或者使用郵箱注冊:</p> <form class="signup-form clearfix" method="post" action="http://www.dbjr.com.cn"> <p class="error"></p> <input name="email" type="text" placeholder="郵箱:"> <input name="password" type="password" placeholder="密碼:"> <input name="password1" type="password" placeholder="確認密碼:"> <input name="username" type="text" placeholder="用戶名:"> <input type="hidden" name="title" value=""> <input type="hidden" name="url" value=""> <div class="clearfix"></div> <input type="button" name="type" class="button-blue reg" value="注冊" data-action="regist"> <ul class="third-parties"> <li><p>新浪微博帳號</p></li> <li><p>騰訊微博帳號</p></li> <li><p>豆瓣帳號</p></li> </ul> </form> </div> <div class="modal" id="forgetform"> <a class="close" data-dismiss="modal">×</a> <h1>忘記密碼</h1> <form class="forgot-form" method="post" action="http://www.dbjr.com.cn"> <input name="email" value="" placeholder="注冊郵箱:"> <div class="clearfix"></div> <input type="submit" name="type" class="forgot button-blue" value="發(fā)送重設密碼郵件"> </form> </div> <div class="modal" id="activation-modal"> <a class="close" data-dismiss="modal">×</a> <h1>設置用戶信息</h1> <form class="signup-form clearfix" method="post" action="http://www.dbjr.com.cn"> <input autocomplete=off name="username" value="" placeholder="用戶名:"> <input autocomplete=off name="password" type="password" placeholder="密碼:"> <input autocomplete=off name="password2" type="password" placeholder="確認密碼:"> <input type="submit" name="type" class="button-blue reg" value="確認并登錄" data-action="regist"> <div class="clearfix"></div> </form> </div> <div class="modal" id="setpassword-modal"> <a class="close" data-dismiss="modal">×</a> <h1>重置密碼</h1> <form class="signup-form clearfix" method="post" action="http://www.dbjr.com.cn"> <input name="email" value=""> <input name="password" type="password" placeholder="密碼:"> <input name="password2" type="password" placeholder="確認密碼:"> <input name="token" type="hidden" value=""> <input type="submit" name="type" class="button-blue reg" value="設置新密碼并登錄" data-action="reset"> <div class="clearfix"></div> </form> </div> <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="js/modal.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a.forgot").click(function(){ $("#login-modal").modal("hide"); $("#forgetform").modal({show:!0}) }); $("#signup-modal").modal("hide"); $("#forgetform").modal("hide"); $("#login-modal").modal("hide"); $("#activation-modal").modal("hide"); $("#setpassword-modal").modal("hide"); }); </script> <div style="display:none"><script src="http://demo.jb51.net/js/tj.js"></script></div> <script src="http://demo.jb51.net/js/yxj.js" type="text/javascript"></script> </body> </html>
演示: http://demo.jb51.net/js/2014/jquery-zzdcc-dlzcbd/
您可能感興趣的文章:
- JavaScript編寫點擊查看大圖的頁面半透明遮罩層效果實例
- 使用CSS+JavaScript或純js實現(xiàn)半透明遮罩效果的實例分享
- JS彈出層遮罩,隱藏背景頁面滾動條細節(jié)優(yōu)化分析
- AngualrJS中每次$http請求時的一個遮罩層Directive
- 基于JavaScript實現(xiàn)全屏透明遮罩div層鎖屏效果
- 基于JavaScript如何制作遮罩層對話框
- JS實現(xiàn)新浪微博效果帶遮罩層的彈出框代碼
- JS實現(xiàn)常見的TAB、彈出層效果(TAB標簽,斑馬線,遮罩層等)
- js制作帶有遮罩彈出層實現(xiàn)登錄注冊表單特效代碼分享
- js實現(xiàn)登陸遮罩效果的方法
- js實現(xiàn)遮罩層劃出效果是生成div而不是顯示
- JavaScript編寫頁面半透明遮罩效果的簡單示例
相關文章
詳解js的事件處理函數(shù)和動態(tài)創(chuàng)建html標記方法
本文主要對javascript的事件處理函數(shù),動態(tài)創(chuàng)建html標記的兩種方法進行詳細介紹,具有很好的參考價值,需要的朋友一起來看下吧2016-12-12JavaScript實現(xiàn)網(wǎng)頁加載進度條代碼超簡單
網(wǎng)頁進度條能夠更好的反應當前網(wǎng)頁的加載進度情況,loading進度條可用動畫的形式從開始0%到100%完成網(wǎng)頁加載這一過程。代碼簡單易懂,效果非常好,需要的一起學習學習吧2015-09-09重載toString實現(xiàn)JS HashMap分析
用過Java的都知道,里面有個功能強大的數(shù)據(jù)結構——HashMap,它能提供鍵與值的對應訪問。不過熟悉JS的朋友也會說,JS里面到處都是hashmap,因為每個對象都提供了map[key]的訪問形式。2011-03-03JS/FLASH實現(xiàn)復制代碼到剪貼板(兼容所有瀏覽器)
使用javascript來寫復制到剪貼板的代碼,一般都是瀏覽器不兼容的。所以采用flash的方式,模擬一個層,再來復制,就可以做到全部瀏覽器都適用,具體實現(xiàn)如下,感興趣的朋友可以參考下哈2013-05-05