jQuery实现的两种简单弹窗效果示例

本文实例讲述了jQuery实现的两种简单弹窗效果。分享给大家供大家参考,具体如下:

这里利用jquery实现两种弹窗效果:

1. 淡入弹窗效果:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>www..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>
    <div class="main">
        <div class="mainbox">
          <div class="close">点击关闭</div>
        </div>
      </div>
    <div class="box">
      <div class="kkk">
        <input class="btn" type="button" value="点击淡入弹窗" />
      </div>
    </div>
  </body>
</html>

运行效果:

jQuery实现的两种简单弹窗效果示例

2. 滑动弹窗效果:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>www..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>
    <div class="main">
        <div class="mainbox">
          <div class="close">点击关闭</div>
        </div>
      </div>
    <div class="box">
      <div class="kkk">
        <input class="btn" type="button" value="点击淡入弹窗" />
      </div>
    </div>
  </body>
</html>

运行效果:

jQuery实现的两种简单弹窗效果示例

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery窗口操作技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery常见经典特效汇总》及《jquery选择器用法总结

希望本文所述对大家jQuery程序设计有所帮助。