基于jQuery實現(xiàn)彈出可關閉遮罩提示框?qū)嵗a
jquery CSS3遮罩彈出層動畫效果,使用非常簡單,就兩個標簽,里面自定義內(nèi)容和樣式,四種常見效果,懂的朋友還可以修改源代碼修改成自己想要的效果
先給大家展示下效果圖,如果大家感覺還不錯,請參考實現(xiàn)代碼。
關鍵代碼如下所示:
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1" /> <title>JQuery-CSS3制作簡潔的彈框_何問起</title> <script type="text/javascript" src="http://down.hovertree.com/jquery/jquery-1.7.2.min.js"></script> <link rel="stylesheet" > <style>.hovertreeinfo{text-align:center;}.hovertreeinfo a{color:blue}</style> </head> <body> <div class="hovertreeinfo"><h2>jquery CSS3制作簡潔遮罩彈出層動畫</h2> 幾種常見的簡潔彈框</div> <div class="checkbox"> <a href="javascript:0;" class="cd-popup-trigger0">樣式1</a> <a href="javascript:0;" class="cd-popup-trigger1">樣式2</a> <a href="javascript:0;" class="cd-popup-trigger2">樣式3</a> <a href="javascript:0;" class="cd-popup-trigger3">樣式4</a> </div> <!--彈框--> <div class="cd-popup"> <div class="cd-popup-container"> <p>何問起</p> <div class="cd-buttons"> 自定義整體容器寬高度及內(nèi)容,高度可自適應可固定,樣式可以定義自己喜歡的樣式,這里就不做美觀了 </div> <a href="javascript:;" class="cd-popup-close">close</a> </div> </div> <div class="cd-popup1"> <div class="cd-popup-container1"> <p>何問起</p> <div class="cd-buttons"> 自定義整體容器寬高度及內(nèi)容,高度可自適應可固定,樣式可以定義自己喜歡的樣式,這里就不做美觀了,更多特效:<a target="_blank">http://hovertree.com/texiao/</a> </div> <a href="javascript:;" class="cd-popup-close">close</a> </div> </div> <div class="cd-popup2"> <div class="cd-popup-container2"> <p>何問起</p> <div class="cd-buttons"> 自定義整體容器寬高度及內(nèi)容,高度可自適應可固定,樣式可以定義自己喜歡的樣式,這里就不做美觀了 </div> <a href="javascript:;" class="cd-popup-close">close</a> </div> </div> <div class="cd-popup3"> <div class="cd-popup-container3"> <p>何問起</p> <div class="cd-buttons"> 自定義整體容器寬高度及內(nèi)容,高度可自適應可固定,樣式可以定義自己喜歡的樣式,這里就不做美觀了 </div> <a href="javascript:;" class="cd-popup-close">close</a> </div> </div> <div class="hovertreeinfo"><a target="_blank">何問起</a> <a target="_blank">網(wǎng)頁特效</a> <a target="_blank">代碼說明</a></div> <script type="text/javascript"> /*彈框JS內(nèi)容*/ jQuery(document).ready(function($){ //打開窗口 $('.cd-popup-trigger0').on('click', function(event){ event.preventDefault(); $('.cd-popup').addClass('is-visible'); //$(".dialog-addquxiao").hide() }); //關閉窗口 $('.cd-popup').on('click', function(event){ if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) { event.preventDefault(); $(this).removeClass('is-visible'); } }); //ESC關閉 $(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup').removeClass('is-visible'); } }); //打開窗口 $('.cd-popup-trigger1').on('click', function(event){ event.preventDefault(); $('.cd-popup1').addClass('is-visible1'); //$(".dialog-addquxiao").hide() }); //關閉窗口 $('.cd-popup1').on('click', function(event){ if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup1') ) { event.preventDefault(); $(this).removeClass('is-visible1'); } }); //ESC關閉 $(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup1').removeClass('is-visible1'); } }); //打開窗口 by 何問起 $('.cd-popup-trigger2').on('click', function(event){ event.preventDefault(); $('.cd-popup2').addClass('is-visible2'); //$(".dialog-addquxiao").hide() }); //關閉窗口 $('.cd-popup2').on('click', function(event){ if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup2') ) { event.preventDefault(); $(this).removeClass('is-visible2'); } }); //ESC關閉 $(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup2').removeClass('is-visible2'); } }); //打開窗口 $('.cd-popup-trigger3').on('click', function(event){ event.preventDefault(); $('.cd-popup3').addClass('is-visible3'); //$(".dialog-addquxiao").hide() }); //關閉窗口 $('.cd-popup3').on('click', function(event){ if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup3') ) { event.preventDefault(); $(this).removeClass('is-visible3'); } }); //ESC關閉 $(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup3').removeClass('is-visible3'); } }); }); </script> </body> </html>
以上所述是小編給大家介紹的基于jQuery實現(xiàn)彈出可關閉遮罩提示框?qū)嵗a,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關文章
利用jQuery實現(xiàn)WordPress中@的ID懸浮顯示評論內(nèi)容
這篇文章主要介紹了使用JavaScript實現(xiàn)WordPress中ID懸浮顯示評論的功能,就是在樓中樓式的評論中顯示被評論的主體內(nèi)容,需要的朋友可以參考下2015-12-12在頁面上用action傳遞參數(shù)到后臺出現(xiàn)亂碼的解決方法
本篇文章主要是對在頁面上用action傳遞參數(shù)到后臺出現(xiàn)亂碼的解決方法進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12jquery基于layui實現(xiàn)二級聯(lián)動下拉選擇(省份城市選擇)
本篇文章主要介紹了jquery基于layui實現(xiàn)二級聯(lián)動下拉選擇(省份城市選擇),具有一定的實用價值,需要的朋友可以參考下2017-06-06jQuery創(chuàng)建自定義的選擇器用以選擇高度大于100的超鏈接實例
這篇文章主要介紹了jQuery創(chuàng)建自定義的選擇器用以選擇高度大于100的超鏈接,實例分析了jQuery自定義選擇器的使用技巧,非常具有實用價值,需要的朋友可以參考下2015-03-03