CSS top 屬性及其動畫用法


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

示例

動態演示

<!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-06-2020

912 次瀏覽

開啟你的職業生涯

完成本課程後獲得認證

開始學習
廣告