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

发布时间:2020-10-26 09:55:14 作者:包子源
来源:脚本之家 阅读:160

本文实例讲述了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>
    <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.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>
    <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程序设计有所帮助。

推荐阅读:
  1. JavaScript如何实现简单的弹窗效果
  2. jquery如何实现弹窗效果

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

jquery 弹窗效果 ue

上一篇:HTML5 Canvas如何实现文本对齐的方法

下一篇:HTML之head头部的实现案例

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》