css左右摇摆动画

html 复制代码
<html>
   <head>
      <style>

         .animated {
           background: red;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes shake {
            0%, 100% {-webkit-transform: translateX(0);}
            10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
            20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
         }

         @keyframes shake {
            0%, 100% {transform: translateX(0);}
            10%, 30%, 50%, 70%, 90% {transform: translateX(-10px);}
            20%, 40%, 60%, 80% {transform: translateX(10px);}
         }

         .shake {
            -webkit-animation-name: shake;
            animation-name: shake;
         }
      </style>

   </head>
   <body>

      <div id = "animated-example" class = "animated shake"></div>
      <button onclick = "myFunction()">Reload page</button>

      <script>
         function myFunction() {
            location.reload();
         }
      </script>
   </body>
</html>

抖动缩放动画

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        @keyframes shake {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.5) translateX(-5px) translateY(-5px);
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(0.5) translateX(5px) translateY(5px);
  }
  100% {
    transform: scale(1);
  }
}

.element {
  animation: shake 1s 1;

  width: 10px;
  height: 10px;
  background: red
}
    </style>
</head>
<body>
    <div class="element">

    </div>
</body>
</html>
相关推荐
EveryPossible13 小时前
带有渐变光晕
前端·javascript·css
卓码软件测评14 小时前
第三方软件登记测试机构:【软件登记测试机构HTML5测试技术】
前端·功能测试·测试工具·html·测试用例·html5
CS Beginner14 小时前
【html】canvas实现一个时钟
前端·html
阿昭L14 小时前
html快速学习
html
qianmo202114 小时前
基于any2web+deepseek实现对三角函数定义的理解
css·html·css3
zhangxuyu11181 天前
flex布局学习记录
前端·css·学习
Never_Satisfied1 天前
在JavaScript / HTML中,`onclick`事件触发多个函数
开发语言·javascript·html
C+ 安口木2 天前
CSS通用优惠券样式
前端·css
蓝莓味的口香糖2 天前
【CSS】flex布局
前端·css
EveryPossible2 天前
第一版代码
前端·javascript·css