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>
相关推荐
zhanshuo1 小时前
不依赖框架,如何用 JS 实现一个完整的前端路由系统
前端·javascript·html
火柴盒zhang1 小时前
websheet在线电子表格(spreadsheet)在集团型企业财务报表中的应用
前端·html·报表·合并·spreadsheet·websheet·集团财务
孤水寒月7 小时前
基于HTML的悬窗可拖动记事本
前端·css·html
祝余呀8 小时前
html初学者第一天
前端·html
Eiceblue15 小时前
使用 C# 发送电子邮件(支持普通文本、HTML 和附件)
开发语言·c#·html·visual studio
涔溪15 小时前
HTML5 实现的圣诞主题网站源码,使用了 HTML5 和 CSS3 技术,界面美观、节日氛围浓厚。
css3·html5·节日
超级土豆粉16 小时前
Turndown.js: 优雅地将 HTML 转换为 Markdown
开发语言·javascript·html
忧郁的蛋~17 小时前
HTML表格导出为Excel文件的实现方案
前端·html·excel
然我17 小时前
别再只用 base64!HTML5 的 Blob 才是二进制处理的王者,面试常考
前端·面试·html
呆呆的心17 小时前
前端必学:从盒模型到定位,一篇搞定页面布局核心 🧩
前端·css