CSS3的過渡效果(transition)與動畫(animation)

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   os   sp   div   

1.Transition

Transition是一種直觀上的效果,讓DOM元素的某個屬性在固定時間內從一舊值到一新值。目前Firefox、Opera、Safari和Chrome都支援transition ,IE還不支援。

文法:transition: property duration timing-function delay;

transition-property  指定的要改變的css屬性名稱

transition-duration 指定過度效果要花多少時間(s/ms)

transition-timing-function 指定過渡效果的速度  (   linear ease ease-in ease-out ease-in-out cubic-bezier(n,n,n,n)   )

值 描述
linear 規定以相同速度開始至結束的過渡效果(等於 cubic-bezier(0,0,1,1))。
ease 規定慢速開始,然後變快,然後慢速結束的過渡效果(cubic-bezier(0.25,0.1,0.25,1))。
ease-in 規定以慢速開始的過渡效果(等於 cubic-bezier(0.42,0,1,1))。
ease-out 規定以慢速結束的過渡效果(等於 cubic-bezier(0,0,0.58,1))。
ease-in-out 規定以慢速開始和結束的過渡效果(等於 cubic-bezier(0.42,0,0.58,1))。
cubic-bezier(n,n,n,n) 在 cubic-bezier 函數中定義自己的值。可能的值是 0 至 1 之間的數值。

transition-delay 定義過渡效果的延遲時間   

lineareaseease-inease-outease-in-out

2. Animation

CSS動畫(Animations)簡單說就是在一段固定的動畫時間內暗中在某一頻率內改變其CSS某個或某些值,從而達到視覺上的轉換動畫效果。Animations的很多方面都是可以控制的,包括動畫已耗用時間,開始值和結束值,還有動畫的暫停和延遲其開始時間等。

目前支援Animation的瀏覽器有:Firefox、 Safari 和 Chrome,IE和Opera還不支援。

文法:animation: name duration timing-function delay iteration-count direction;

屬性 描述 CSS
@keyframes 規定動畫。 3
animation 所有動畫屬性的簡寫屬性,除了 animation-play-state 屬性。 3
animation-name 規定 @keyframes 動畫的名稱。 3
animation-duration 規定動畫完成一個周期所花費的秒或毫秒。預設是 0。 3
animation-timing-function 規定動畫的速度曲線。預設是 "ease"。 3
animation-delay 規定動畫何時開始。預設是 0。 3
animation-iteration-count 規定動畫被播放的次數。預設是 1。 3
animation-direction 規定動畫是否在下一周期逆向地播放。預設是 "normal"。 3
animation-play-state 規定動畫是否正在運行或暫停。預設是 "running"。 3
animation-fill-mode 規定對象動畫時間之外的狀態。 3
 

 

 

CSS3的過渡效果(transition)與動畫(animation)

聯繫我們

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