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

CSSを使用してbackground-positionプロパティでアニメーションを実行する


@keyframesを使用して、背景の位置をアニメーション化します。 CSSを使用してbackground-positionプロパティにアニメーションを実装するには、次のコードを実行してみてください

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 500px;
            height: 400px;
            background: yellow;
            background-image: url('https://www.tutorialspoint.com/latest/microservice_architecture.png');
            animation: myanim 3s infinite;
            background-position: bottom left;
         }
         @keyframes myanim {
            20% {
               background-color: maroon;
               background-position: bottom right;
            }
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>

  1. CSSのpadding-topプロパティでアニメーションを実行する

    CSSを使用してpadding-topプロパティにアニメーションを実装するには、次のコードを実行してみてください- 例 <!DOCTYPE html> <html>    <head>       <style>          div {             width: 350px;             heig

  2. CSSアニメーションを使用して変換プロパティをアニメーション化する

    変換にアニメーションを実装するには CSSでプロパティを使用すると、次のコードを実行してみることができます- 例 <!DOCTYPE html> <html>    <head>       <style>          div {             margin: auto;             border: 2