JS---案例:开机动画

案例:开机动画

由上下两部分组成,先下面的高变为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>

猜你喜欢

转载自www.cnblogs.com/jane-panyiyun/p/12081682.html
今日推荐