css動畫

  • 用的屬性爲animation

    • 實例:

      <!DOCTYPE html>
      <html>
      <head>
      <style> 
      div
      {
      width:100px;
      height:100px;
      background:red;
      position:relative;
      animation:mymove 5s infinite;  // mymove 動畫名字 5s表示運動五秒,infinite表示無限循環
      }
      
      @keyframes mymove
      {
      from {left:0px;}
      to {left:200px;}    
      }
      </style>
      </head>
      <body>
      <div></div>
      </body>
      </html>
    • animation語法

描述
animation-name 規定須要綁定到選擇器的 keyframe 名稱。。
animation-duration 規定完成動畫所花費的時間,以秒或毫秒計。
animation-timing-function 規定動畫的速度曲線。
animation-delay 規定在動畫開始以前的延遲。
animation-iteration-count 規定動畫應該播放的次數。
animation-direction 規定是否應該輪流反向播放動畫。
  • animation特例

    • 在keyframes中的,0%表示開始位置,100%表示結束位置。css

    • 當想要動畫結束的位置,能夠用:animation-fill-mode。html

    • 當想要設置動畫只出現一次的時候,至少要有兩個過程。動畫

      例子
      .container img{
          animation: photo 5s 1 linear;
          animation-fill-mode: forwards;
      }
      
      @keyframes photo{
          0%{
              bottom: -45px;
          }
          100%{
              bottom: 0px;
          }
      }
相關文章
相關標籤/搜索