css的動畫和過渡

來源:互聯網
上載者:User

標籤:

一、過渡:

transition    簡寫屬性,用於在一個屬性中設定四個過渡屬性。

transition-property   規定應用過渡的 CSS 屬性的名稱。

transition-duration    定義過渡效果花費的時間。預設是 0。

transition-timing-function   規定過渡效果的時間曲線。預設是 "ease"。

transition-delay         規定過渡效果何時開始。預設是 0。

eg:

div{transition: width 1s linear 2s;/* Firefox 4 */-moz-transition:width 1s linear 2s;/* Safari and Chrome */-webkit-transition:width 1s linear 2s;/* Opera */-o-transition:width 1s linear 2s;}
二、動畫:

@keyframes 規則用於建立動畫。在 @keyframes 中規定某項 CSS 樣式,就能建立由當前樣式逐漸改為新樣式的動畫效果。

1、animation    所有動畫屬性的簡寫屬性,除了 animation-play-state 屬性。

2、animation-name     規定 @keyframes 動畫的名稱。

3、animation-duration   規定動畫完成一個周期所花費的秒或毫秒。預設是 0。

4、animation-timing-function      規定動畫的速度曲線。預設是 "ease"。

5、animation-delay       規定動畫何時開始。預設是 0。

6、animation-iteration-count       規定動畫被播放的次數。預設是 1。

7、animation-direction      規定動畫是否在下一周期逆向地播放。預設是 "normal"。

8、animation-play-state    規定動畫是否正在運行或暫停。預設是 "running"。

9、animation-fill-mode      規定對象動畫時間之外的狀態。

eg:

div{animation: myfirst 5s linear 2s infinite alternate;/* Firefox: */-moz-animation: myfirst 5s linear 2s infinite alternate;/* Safari 和 Chrome: */-webkit-animation: myfirst 5s linear 2s infinite alternate;/* Opera: */-o-animation: myfirst 5s linear 2s infinite alternate;}


 


css的動畫和過渡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.