您好,欢迎访问一九零五行业门户网

jQuery实现弹窗效果(附代码)

这次给大家带来jquery实现弹窗效果(附代码),jquery实现弹窗效果的注意事项有哪些,下面就是实战案例,一起来看一下。
这里利用jquery实现两种弹窗效果:
1. 淡入弹窗效果:
<!doctype html> <html>   <head>     <meta charset="utf-8">     <title>www.jb51.net jquery弹窗</title>     <style>       *{padding: 0;margin: 0;}       .box{width: 100%;height: 100%;}       .main{width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);display: none;position: fixed;z-index: 1;}       .mainbox{width: 800px;height: 100%;margin: 0 auto;background-color: rgba(255,255,255,0.8);padding: 20px;}       .kkk{width: 100%;height: 1200px;background-color: red;}       .close{color: red;cursor: pointer;}     </style>     <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>     <script>       $(function(){         $(.btn).click(function(){           $(.main).fadein();         });         $(.close).click(function(){           $(.main).fadeout();         });       });     </script>   </head>   <body>     <p class="main">         <p class="mainbox">           <p class="close">点击关闭</p>         </p>       </p>     <p class="box">       <p class="kkk">         <input class="btn" type="button" value="点击淡入弹窗" />       </p>     </p>   </body> </html>
运行效果:
2. 滑动弹窗效果:
<!doctype html> <html>   <head>     <meta charset="utf-8">     <title>www.jb51.net jquery弹窗</title>     <style>       *{padding: 0;margin: 0;}       .box{width: 100%;height: 100%;}       .main{width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);display: none;position: fixed;z-index: 1;}       .mainbox{width: 800px;height: 100%;margin: 0 auto;background-color: rgba(255,255,255,0.8);padding: 20px;display: none;}       .kkk{width: 100%;height: 1200px;background-color: red;}       .close{color: red;cursor: pointer;}     </style>     <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>     <script>       $(function(){         $(.btn).click(function(){           $(.main).fadein();           $(.mainbox).delay(500).slidedown();         });         $(.close).click(function(){           $(.main).fadeout();         });       });     </script>   </head>   <body>     <p class="main">         <p class="mainbox">           <p class="close">点击关闭</p>         </p>       </p>     <p class="box">       <p class="kkk">         <input class="btn" type="button" value="点击淡入弹窗" />       </p>     </p>   </body> </html>
运行效果:
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
js数组方法总结
js仿jquery步骤详解
以上就是jquery实现弹窗效果(附代码)的详细内容。
其它类似信息

推荐信息