使用 CSS 對背景位置屬性進行動畫處理


使用 @keyframes 對背景位置進行動畫處理。若要使用 CSS 對 background-position 屬性實施動畫處理,你可以嘗試執行以下程式碼

例項

現場演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 500px;
            height: 400px;
            background: yellow;
            background-image: url('https://tutorialspoint.tw/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>

更新於: 25-6月-2020

332 檢視

開啟你的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.