具有動畫的 CSS top 屬性


若要實現top屬性以 CSS 的動畫效果,可以嘗試執行以下程式碼 −

示例

實際演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            position: absolute;
            width: 300px;
            height: 200px;
            background-color: orange;
            color: white;
            top: 0;
            animation: myanim 3s infinite;
         }
         @keyframes myanim {
            30% {
               top: 300px;
            }
         }
      </style>
   </head>
   <body>
      <h1>CSS top property</h1>
      <div>
         <h1>This is demo text!</h1>
      </div>
   </body>
</html>

更新時間: 12-Jun-2020

910 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始吧
廣告