当前位置: 移动技术网 > IT编程>开发语言>JavaScript > JS---案例:开机动画

JS---案例:开机动画

2019年12月23日  | 移动技术网IT编程  | 我要评论

案例:开机动画

由上下两部分组成,先下面的高变为0 ,再最大的div宽为0,形成一个缩小到没有的动画效果

点击的x是在背景图上的,在上面设置了一个空的span用于注册点击事件

 

<!doctype html>
<html>

<head lang="en">
  <meta charset="utf-8">
  <title></title>
  <style>
    .box {
      width: 322px;
      position: fixed;
      bottom: 0;
      right: 0;
      overflow: hidden;
    }

    span {
      position: absolute;
      top: 0;
      right: 0;
      width: 30px;
      height: 20px;
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div class="box" id="box">
    <span id="closebutton"></span>
    <div class="hd" id="headpart">
      <img src="images/t.jpg" alt="" />
    </div>
    <div class="bd" id="bottompart">
      <img src="images/b.jpg" alt="" />
    </div>
  </div>
  <script src="common.js"></script>
  <script>

    my$("closebutton").onclick = function () {
      //设置最下面的div高渐渐变为0,里面加个回掉函数
      animate(my$("bottompart"), { "height": 0 }, function () {
        animate(my$("box"), { "width": 0 });
      });
    };

  </script>
</body>

</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网