当前位置: 移动技术网 > IT编程>开发语言>JavaScript > JavaScript实现简单的弹窗效果

JavaScript实现简单的弹窗效果

2020年06月14日  | 移动技术网IT编程  | 我要评论

西乡县政府网,韦君梓,广州圣芭芭拉

本文实例为大家分享了javascript实现弹窗效果的具体代码,供大家参考,具体内容如下

使用css动画效果实现弹窗缓慢弹出和收回。

使用javascript实现定时弹出定时收回。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>简单弹窗</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>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网