ホームページ  >  記事  >  ウェブフロントエンド  >  CSSを使用したフェードアニメーション効果

CSSを使用したフェードアニメーション効果

WBOY
WBOY転載
2023-08-30 15:53:071188ブラウズ

使用 CSS 淡入淡出动画效果

#CSS を使用して画像に大きなフェードイン アニメーション効果を実現するには、次のコードを実行してみてください -

Example

ライブデモンストレーション
<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: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes fadeInDown {
            0% {
               opacity: 0;
               -webkit-transform: translateY(-20px);
            }
            100% {
               opacity: 1;
               -webkit-transform: translateY(0);
            }
         }

         @keyframes fadeInDown {
            0% {
               opacity: 0;
               transform: translateY(-20px);
            }
            100% {
               opacity: 1;
               transform: translateY(0);
            }
         }

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

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

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

   </body>
</html>

以上がCSSを使用したフェードアニメーション効果の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はtutorialspoint.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。