CSS
 Computer >> コンピューター >  >> プログラミング >> CSS

CSSでアニメーション効果をバウンス


バウンスアニメーション効果は、要素をヒットした後、要素をすばやく上下に移動したり、サーフェスから遠ざけたりするために使用されます。

次のコードを実行して、バウンスアニメーション効果を実装してみてください-

<html>
   <head>
      <style>

         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 1s;
            animation-duration: 1s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes bounce {
            0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);}
            40% {-webkit-transform: translateY(-30px);}
            60% {-webkit-transform: translateY(-15px);}
         }

         @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
            40% {transform: translateY(-30px);}
            60% {transform: translateY(-15px);}
         }

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

   </head>
   <body>

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

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

  1. CSSを使用したウォブルアニメーション効果

    CSSでウォブルアニメーション効果を作成するには、次のコードを実行してみてください- 例 <html>    <head>       <style>          .animated {             background-image: url(/css/images/logo.png);             backgr

  2. CSSを使用した多田アニメーション効果

    CSSを使用してTadaアニメーション効果を作成するには、次のコードを実行してみてください。 例 <html>    <head>       <style>          .animated {             background-image: url(/css/images/logo.png);             ba