js實(shí)現(xiàn)點(diǎn)擊彈窗彈出登錄框
本文實(shí)例為大家分享了js實(shí)現(xiàn)點(diǎn)擊彈窗彈出登錄框的具體代碼,供大家參考,具體內(nèi)容如下
1 圖片預(yù)覽
2 index.html代碼
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>js點(diǎn)擊彈窗彈出登錄框代碼</title> </head> <body> <style> *{ margin:0; padding:0; } button, input{ outline:none; } button, .login{ width:120px; height:42px; background:#f40; color:#fff; border:none; border-radius:6px; display: block; margin:20px auto; cursor: pointer; } .popOutBg{ width:100%; height:100%; position: fixed; left:0; top:0; background:rgba(0,0,0,.6); display: none; } .popOut{ position:fixed; width:600px; height:300px; top:50%; left:50%; margin-top:-150px; margin-left:-300px; background:#fff; border-radius:8px; overflow: hidden; display: none; } .popOut > span{ position: absolute; right:10px; top:0; height:42px; line-height:42px; color:#000; font-size:30px; cursor: pointer; } .popOut table{ display: block; margin:42px auto 0; width:520px; } .popOut caption{ width:520px; text-align: center; color:#f40; font-size:18px; line-height:42px; } .popOut table tr td{ color:#666; padding:6px; font-size:14px; } .popOut table tr td:first-child{ text-align: right; } .inp{ width:280px; height:30px; line-height:30px; border:1px solid #999; padding:5px 10px; color:#000; font-size:14px; border-radius:6px; } .inp:focus{ border-color:#f40; } @keyframes ani{ from{ transform:translateX(-100%) rotate(-60deg) scale(.5); } 50%{ transform:translateX(0) rotate(0) scale(1); } 90%{ transform:translateX(20px) rotate(0) scale(.8); } to{ transform:translateX(0) rotate(0) scale(1); } } .ani{ animation:ani .5s ease-in-out;} </style> <button type="button">登錄</button> <div class="popOutBg"></div> <div class="popOut"> <span title="關(guān)閉"> x </span> <table> <caption>歡迎登錄本網(wǎng)站</caption> <tr> <td width="120">用戶名:</td> <td><input type="text" class="inp" placeholder="請輸入用戶名" /></td> </tr> <tr> <td>密碼:</td> <td><input type="password" class="inp" placeholder="請輸入密碼" /></td> </tr> <tr> <td colspan="2"><input type="button" class="login" value="登錄" /></td> </tr> </table> </div> <script type="text/javascript"> function $(param) { if (arguments[1] == true) { return document.querySelectorAll(param); } else { return document.querySelector(param); } } function ani() { $(".popOut").className = "popOut ani"; } $("button").onclick = function() { $(".popOut").style.display = "block"; ani(); $(".popOutBg").style.display = "block"; }; $(".popOut > span").onclick = function() { $(".popOut").style.display = "none"; $(".popOutBg").style.display = "none"; }; $(".popOutBg").onclick = function() { $(".popOut").style.display = "none"; $(".popOutBg").style.display = "none"; }; </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Web性能優(yōu)化系列 10個提升JavaScript性能的技巧
Javascript 性能優(yōu)化絕不是一種書面的技術(shù),Nicholas 的技術(shù)演進(jìn)列出了10條建議,幫助你寫出高效的 JS 代碼2016-09-09js, jQuery實(shí)現(xiàn)全選、反選功能
本文主要介紹了js, jQuery實(shí)現(xiàn)全選、反選功能的方法,具有很好的參考價值。下面跟著小編一起來看下吧2017-03-03基于BootstrapValidator的Form表單驗(yàn)證(24)
這篇文章主要為大家詳細(xì)介紹了基于BootstrapValidator的Form表驗(yàn)證,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12關(guān)于安卓手機(jī)微信瀏覽器中使用XMLHttpRequest 2上傳圖片顯示字節(jié)數(shù)為0的解決辦法
這篇文章主要介紹了關(guān)于安卓手機(jī)微信瀏覽器中使用XMLHttpRequest 2上傳圖片顯示字節(jié)數(shù)為0的解決辦法 的相關(guān)資料,需要的朋友可以參考下2016-05-05使用JavaScript實(shí)現(xiàn)一個拖拽縮放效果
這篇文章主要介紹了如何使用JS實(shí)現(xiàn)一個這樣的拖拽縮放效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05Bootstrap開發(fā)中Tab標(biāo)簽頁切換圖表顯示問題的解決方法
這篇文章主要給大家介紹了關(guān)于Bootstrap開發(fā)中Tab標(biāo)簽頁切換圖表顯示問題的解決方法,文中通過圖文以及示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-07-07javascript結(jié)合CSS實(shí)現(xiàn)蘋果開關(guān)按鈕特效
這篇文章主要介紹了javascript結(jié)合CSS實(shí)現(xiàn)蘋果開關(guān)按鈕特效的方法以及全部代碼,效果非常不錯,兼容性也很好,有需要的小伙伴自己參考下2015-04-04