JavaScript實(shí)現(xiàn)簡單的彈窗效果
本文實(shí)例為大家分享了JavaScript實(shí)現(xiàn)彈窗效果的具體代碼,供大家參考,具體內(nèi)容如下
使用css動畫效果實(shí)現(xiàn)彈窗緩慢彈出和收回。
使用JavaScript實(shí)現(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 id='pop'> <img src='http://www.cgvv.com.cn/bcjs/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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Struts2獲取參數(shù)的三種方法總結(jié)2. JSP中Servlet的Request與Response的用法與區(qū)別3. IntelliJ IDEA刪除類的方法步驟4. js select支持手動輸入功能實(shí)現(xiàn)代碼5. Android 實(shí)現(xiàn)徹底退出自己APP 并殺掉所有相關(guān)的進(jìn)程6. vue cli4下環(huán)境變量和模式示例詳解7. vue使用moment如何將時間戳轉(zhuǎn)為標(biāo)準(zhǔn)日期時間格式8. Django視圖類型總結(jié)9. IntelliJ IDEA導(dǎo)入jar包的方法10. Xml簡介_動力節(jié)點(diǎn)Java學(xué)院整理
