css3中的 @Keyframes

來源:互聯網
上載者:User

標籤:

一、介紹

keyframes被稱為主要畫面格,其類似於Flash中的主要畫面格。在CSS3中其主要以“@keyframes”開頭,後面跟著是動畫名稱加上一對花括弧“{…}”,括弧中是一些不同時間段樣式規則。

文法:@keyframes animationname {keyframes-selector{css-styles;}}

在@keyframes中定義動畫名稱時,其中0%和100%還可以使用關鍵詞from和to來代表,其中0%對應的是from,100%對應的是to。

在一個“@keyframes”中的樣式規則可以由多個百分比構成的,如在“0%”到“100%”之間建立更多個百分比,分別給每個百分比中給需要有動畫效果的元素加上不同的樣式,從而達到

一種在不斷變化的效果。

舉個栗子:

@keyframes changecolor{  0%{    background: red;  }  20%{    background:blue;  }  40%{    background:orange;  }  60%{    background:green;  }  80%{    background:yellow;  }  100%{    background: red;  }}div {  width: 150px;  height: 100px;  background: red;  color:#fff;  margin: 20px auto;}div:hover {  animation: changecolor 5s ease-out .2s;}

  

 

css3中的 @Keyframes

聯繫我們

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