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>
相关推荐
知秋正在9961 小时前
Java实现Html保存为.mhtml文件
java·开发语言·html
棒棒的唐1 小时前
使用微信小程序版Vant的upload组件上传身份证的样式自定义方案(Css魔改版)
css·微信小程序·小程序
DEMO派1 小时前
CSS优先级规则以及如何提升优先级方案详解
前端·javascript·css·vue.js·reactjs·html5·angular.js
NEXT061 小时前
CSS基础-标准盒模型与怪异盒模型
前端·css
@Autowire2 小时前
CSS 中 px、%、vh、vw 这四种常用单位的区别
前端·css
怕浪猫2 小时前
React从入门到出门第七章 管理你的CSS 模块化样式控制方案
javascript·css·react.js
@Autowire2 小时前
CSS 中「继承属性」的核心知识,包括哪些属性可继承、继承的规则、如何控制继承(继承/取消继承)
前端·css
天天向上10242 小时前
css Grid常用布局
前端·css
syty20202 小时前
RedisTemplate方法汇总
前端·bootstrap·html
AI陪跑3 小时前
解决 React + GrapesJS iframe 中 CSS-in-JS 样式隔离问题
javascript·css·react.js