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>
相关推荐
疯狂的魔鬼11 小时前
精确计算容器剩余视口高度:useAutoContainerFullHeight 的工程实践
前端·css·typescript
用户0595401744611 小时前
用了 3 个月 ChatGPT,才发现它一直在遗忘——用 Playwright 自动化验证记忆存储一致性
前端·css
spmcor11 小时前
CSS 黏性定位完全指南:从入门到精通
css
用户0595401744612 小时前
用了半年 LangChain Memory,才发现回滚测试压根没测对
前端·css
丨我是张先生丨1 天前
日语单词 Web Page
前端·css·css3
2501_930707781 天前
如何将HTML文件转换为纯文本(详细步骤指南)
前端·html
吃西瓜不吐籽_1 天前
2026 届前端校招冲刺:2 万字高频面试题库(含详解、追问与评分标准)
前端·javascript·css·typescript·前端框架·es6
Csvn2 天前
CSS :has() 选择器实战:没有它之前我们写了多少冗余 JS
前端·css
用户059540174463 天前
大模型长上下文遗忘排查实录:用 Playwright 自动化测试,揪出了 90% 的存储序列化 bug
前端·css
天蓝色的鱼鱼4 天前
关于 CSS 你可能不知道的属性,但关键时刻很有用
前端·css