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>
相关推荐
吴长建先生重名了18 小时前
用 MinIO 分布式存储模块一次讲清代码重构与整洁代码实
css
cindershade18 小时前
把响应式做成可验证的状态切换:Container Queries 的组件级重构方法
css·flexbox·前端工程化
labixiong18 小时前
z-index: 99999 输给 z-index: 2?原生弹窗的 Top Layer 排位战:后进者居上、看得见却点不着
前端·html
芳心粽伙饭18 小时前
HTML第八章 表单标签
前端·html
weixin_4407305019 小时前
pytest结合allure生成html测试报告(step、story、severity、screenshot)
前端·html·pytest·allure报告
用户2986985301419 小时前
在 React 中实现 RTF 与 PDF、HTML 的文档转换实践
javascript·react.js·html
3A Cloud19 小时前
Huashu Design:把 AI Agent 变成一间以 HTML 为画布的设计工作室
前端·人工智能·html
zhanghaha131419 小时前
Python进阶教程:24_Markdown 转 HTML 零基础超详细教程
开发语言·python·html
芳心粽伙饭19 小时前
HTML第七章 表格标签
前端·html
IMPYLH20 小时前
HTML 的 <option> 元素
服务器·数据库·html