這篇文章主要講解了JavaScript如何實(shí)現(xiàn)簡(jiǎn)單的彈窗效果,內(nèi)容清晰明了,對(duì)此有興趣的小伙伴可以學(xué)習(xí)一下,相信大家閱讀完之后會(huì)有幫助。
使用css動(dòng)畫效果實(shí)現(xiàn)彈窗緩慢彈出和收回。
使用JavaScript實(shí)現(xiàn)定時(shí)彈出定時(shí)收回。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>簡(jiǎn)單彈窗</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>
當(dāng)前題目:JavaScript如何實(shí)現(xiàn)簡(jiǎn)單的彈窗效果-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)鏈接:http://jinyejixie.com/article40/dcjpho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開(kāi)發(fā)、網(wǎng)站內(nèi)鏈、做網(wǎng)站、定制開(kāi)發(fā)、建站公司、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容