css3中的動畫處理

來源:互聯網
上載者:User

標籤:

動畫--過渡屬性 
 div {        width: 200px;        height: 200px;        background: red;        margin: 20px auto;       /* -webkit-transition-property: -webkit-border-radius;        transition-property: border-radius;*/        -webkit-transition-property: width;  /*過渡*/        transition-property: width;        -webkit-transition-duration:.5s;  /*完成過渡所需的時間*/        transition-duration:.5s;        -webkit-transition-timing-function: ease-in;  /*慢速開始的過渡*/        transition-timing-function: ease-in;        -webkit-transition-delay: .18s;   /*開始出現的延遲時間*/        transition-delay:.18s;    }    div:hover {  transition: all .28s ease-in .1s;  /*從正方形的效果,慢慢過渡到圓角*/        width: 400px;    }
 /*    transition-property:指定過渡或動態類比的CSS屬性    transition-duration:指定完成過渡所需的時間,設定過渡動畫的期間    transition-timing-function:指定過渡函數    transition-delay:指定開始出現的延遲時間,指定一個動畫開始執行的時間    /*transition-timing-function包括以下幾種函數:    ease        預設值,速度由快到慢,逐漸層慢    linear      恒速    ease-in     漸加效果,加速速度越來越快    ease-out    漸隱效果,減速速度越來越慢    ease-in-out 先加速再減速*/

 

Keyframes被稱為主要畫面格 以“@keyframes”開頭
@keyframes changecolor{ 聲明的動畫可自己定義    0%{        background: red;    }    40% {        background:orange;    100%{        background: green;    }    }

 

 div{animation-iteration-count:infinite;  /*無限迴圈*/        animation-iteration-count:5; /*用來定義動畫的播放次數*/        animation-name:move;   /*為 @keyframes 動畫規定一個名稱:*/        animation-direction:alternate;  /*設定動畫的播放方向*/        animation-play-state:paused; /*頁面載入時動畫不播放*/    }

 

設定動畫播放方向  animation-direction
其主要有兩個值:normal、alternate

1、normal是預設值,如果設定為normal時,動畫的每次迴圈都是向前播放;
2、另一個值是alternate,他的作用是,動畫播放在第偶數次向前播放,第奇數次向反方向播放。

 1 <div><span></span></div> 2  3                          div { 4                              width: 200px; 5                              height: 200px; 6                              border: 1px solid red; 7                              margin: 20px auto; 8                          } 9     span {10         display: inline-block;11         width: 20px;12         height: 20px;13         background: orange;14         transform: translateY(90px);15         animation-name: move;16         animation-duration: 10s;17         animation-timing-function: ease-in;18         animation-delay: .2s;19         animation-iteration-count:infinite;20         animation-direction:alternate;21     }22 23     @keyframes move {24         0%{25             transform: translateY(90px);26         }27         15%{28             transform: translate(90px,90px);29         }30         30%{31             transform: translate(180px,90px);32         }33         45%{34             transform: translate(90px,90px);35         }36         60%{37             transform: translate(90px,0);38         }39         75%{40             transform: translate(90px,90px);41         }42         90%{43             transform: translate(90px,180px);44         }45         100%{46             transform: translate(90px,90px);47         }48     }

 

css3中的動畫處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.