JavaScript實現(xiàn)登錄窗體
更新時間:2021年06月22日 09:52:21 作者:妄癡夢中
這篇文章主要為大家詳細(xì)介紹了JavaScript實現(xiàn)登錄窗體,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了JavaScript實現(xiàn)登錄窗體的具體代碼,供大家參考,具體內(nèi)容如下
思路:就是把登陸窗放在界面之外,然后通過script內(nèi)的函數(shù)改變到界面之內(nèi)!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>我的登錄窗體</title> <style> .loginDiv{ /*設(shè)置登錄框的外觀*/ border: solid red 3px; border-radius: 10px; width: 350px; height: 250px; background-color: skyblue; /*設(shè)置登錄框的位置*/ position: absolute; top: -300px; } button{ /*設(shè)置button的樣式*/ border-radius: 3px; } #closeDiv{ /*設(shè)置關(guān)閉按鈕位置*/ position: relative; top: -160px; left: 305px; } </style> </head> <body> <a href="javaScript:login()" >登錄窗</a> <div class="loginDiv" id="loginDiv"> <h2 align="center">登錄窗口</h2> <table align="center"> <tr> <th>用戶名:</th> <th><input type="text"></th> </tr> <tr> <th>密碼:</th> <th><input type="password"></th> </tr> <tr> <th colspan="2"> <button>登錄</button>  <button type="reset">重置</button> </th> </tr> </table> <div id="closeDiv"><a href="javaScript:close()" >[關(guān)閉]</a></div> </div> <script> function login() { //獲得登錄對象 let loginDivObj = document.getElementById("loginDiv"); loginDivObj.style.top="100px"; //設(shè)置過渡屬性,參一:transitionProperty:規(guī)定應(yīng)用過渡效果的 CSS 屬性的名稱。 // 參二:transitionDuration:規(guī)定完成過渡效果需要多少秒或毫秒。 // 參三:transitionTimingFunction:規(guī)定過渡效果的速度曲線。 // 參四:transitionDelay:定義過渡效果何時開始。 loginDivObj.style.transition="top 600ms linear 500ms"; } function close() { //獲得登錄對象 let loginDivObj = document.getElementById("loginDiv"); loginDivObj.style.top="-300px"; } </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
用戶引導(dǎo)插件driverjs的基本使用以及彈窗樣式修改方法
Driver.js是一個強大的、輕量級、使用原生JavaScript引擎開發(fā)的庫,用于在頁面聚焦用戶的關(guān)注點,下面這篇文章主要介紹了用戶引導(dǎo)插件driverjs的基本使用以及彈窗樣式修改方法,需要的朋友可以參考下2024-04-04動態(tài)的創(chuàng)建一個元素createElement及刪除一個元素
本文用示例為大家介紹下動態(tài)創(chuàng)建一個元素createElement及刪除一個元素,感興趣的朋友可以參考下2014-01-01js console.log打印對像與數(shù)組用法詳解
這篇文章主要介紹了js console.log打印對像與數(shù)組用法,結(jié)合實例形式較為詳細(xì)的分析了js使用console.log實現(xiàn)打印對象與數(shù)組的具體實現(xiàn)步驟與相關(guān)技巧,需要的朋友可以參考下2016-01-01JavaScript 關(guān)鍵字屏蔽實現(xiàn)函數(shù)
JavaScript屏蔽關(guān)鍵字,大概的思路就是去用javascript去替換已有的文本,達(dá)到替換的目的2009-08-08詳解JavaScript Promise和Async/Await
這篇文章主要介紹了JavaScript Promise和Async/Await,對異步編程感興趣的同學(xué),可以參考下2021-04-04