JavaScript實現(xiàn)簡單的彈窗效果
更新時間:2020年05月19日 08:30:50 作者:安心寫bug
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)簡單的彈窗效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了JavaScript實現(xiàn)彈窗效果的具體代碼,供大家參考,具體內容如下
使用css動畫效果實現(xiàn)彈窗緩慢彈出和收回。
使用JavaScript實現(xiàn)定時彈出定時收回。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>簡單彈窗</title> <style> * { margin: 0; padding: 0; } .pop { width: 400px; height: 300px; position: fixed; bottom: 0; right: 0; display: none; animation: pop 1s ease-in-out 0s; } @keyframes pop { from { height: 0; } to { height: 300px; } } .down { width: 400px; height: 0; position: fixed; bottom: 0; right: 0; display: block; animation: out 1s ease-in-out; } @keyframes out { from { height: 300px; } to { height: 0; } } .img1 { width: 400px; height: 300px; vertical-align: top; } </style> </head> <body> <div class="pop" id="pop"> <img src="images/01.jpg" alt="" class="img1"> </div> </body> <script> window.onload = function () { timer = window.setInterval(imgBlock, 2000); }; function imgBlock() { var pop = document.getElementById('pop'); pop.style.display = 'block'; timer2 = window.setInterval(imgNone,5000); } function imgNone() { var pop = document.getElementById('pop'); pop.className = 'down'; clearInterval(timer); clearInterval(timer2); } </script> </html>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
javascript將數(shù)字轉換整數(shù)金額大寫的方法
這篇文章主要介紹了javascript將數(shù)字轉換整數(shù)金額大寫的方法,通過自定義函數(shù)中的數(shù)組替換實現(xiàn)數(shù)字轉換整數(shù)金額大寫的功能,非常具有實用價值,需要的朋友可以參考下2015-01-01javascript筆記 String類replace函數(shù)的一些事
加固javascript基礎知識目的是為以后研究jQuery源碼做好鋪墊。2011-09-09利用JS獲取IE客戶端IP及MAC的實現(xiàn)好象不可以
利用JS獲取IE客戶端IP及MAC的實現(xiàn)好象不可以...2007-01-01