纯html+css实现的页面加载小球弹跳动画,没用js有缺陷。。

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    body {
      height: 600px;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .wrap {
      width: 400px;
      height: 400px;
      background-color: aqua;
      position: relative;
    }

    .bottom {
      position: absolute;
      width: 200px;
      height: 50px;
      background-color: red;
      left: 50%;
      bottom: 50px;
      transform: translate(-50%, 0);
      overflow: hidden;
      border-radius: 10px;
    }

    .bottom::after {
      content: "";
      width: 50px;
      height: 50px;
      position: absolute;
      top: -25px;
      left: 50%;
      border-radius: 0 0 50% 50%;
      transform: translate(-50%, 0);
      background-color: blueviolet;
      animation-name: radiusclose;
      animation-duration: 2s;
    }

    @keyframes radiusclose {
      0% {
        height: 50px;
      }

      50% {
        height: 0;
      }
    }

    .ball {
      position: absolute;
      width: 40px;
      height: 40px;
      left: 50%;
      bottom: 85px;
      background-color: blue;
      border-radius: 50%;
      transform: translate(-50%, 0);
      animation-name: ballup;
      animation-duration: 2s;
      z-index: 100;
    }

    @keyframes ballup {
      0% {
        transform: translate(-50%, 0);
        width: 40px;
        border-radius: 50%;
      }


      25% {
        transform: translate(-50%, -40px);
        border-radius: 50%;
      }

      29% {
        transform: translate(-50%, -32px);
        border-radius: 50%;
      }

      30% {
        width: 40px;
      }

      32% {
        width: 40px;
        border-radius: 10px;
      }

      50% {
        width: 200px;
        transform: translate(-50%, -35px);
      }

      68% {
        width: 40px;
        border-radius: 10px;
      }

      70% {
        width: 40px;
      }

      71% {
        transform: translate(-50%, -32px);
        border-radius: 50%;
      }

      75% {
        transform: translate(-50%, -40px);
      }


      100% {
        transform: translate(-50%, 0);
        width: 40px;
        border-radius: 50%;
      }

    }
  </style>
</head>

<body>
  <div class="wrap">
    <div class="hello"></div>
    <a id="ball" href="" class="ball"></a>
    <div class="bottom"></div>
  </div>
  <script>

  </script>
</body>

</html>


用js直接修改类名做出动画效果可能好点,a标签不停刷新页面产生动画不太可取,但只用html加css暂时还没有什么更好办法。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值