成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

CSS(Cascading Style Sheets)樣式更改——過渡、動畫

開發 前端
這篇文章我們來介紹下CSS樣式更改中的過渡、動畫基礎用法。

[[347721]]

前言
這篇文章我們來介紹下CSS樣式更改中的過渡、動畫基礎用法。

1.過渡
元素從一種樣式逐漸改變為另一種的樣式 。

  1. div 
  2. transition: width 1s; 
  3. -moz-transition: width 1s;  /* Firefox 4 */ 
  4. -webkit-transition: width 1s;  /* Safari 和 Chrome */ 
  5. -o-transition: width 1s;  /* Opera */ 
  6. transition-property:應用過渡的Css屬性的名稱 比如寬度width 
  7. transition-duration:過渡效果花費的時間   比如1s 
  8. transition-timing-function:渡效果的時間曲線 如下所示: 
  9. linear 勻速 
  10. ease 先慢后快 
  11. ease-in 慢速開始 
  12. ease-out 慢速結束 
  13. ease-in-out 慢速開始和結束 
  14. cubic-bezier(n,n,n,n) 在cubic-bezie 函數中定義自己的值,可能的值是0至1之間的數值 
  15. transition-delay:過渡效果何時開始 如1s 

2.動畫 Animation
1).首先定義@keyframes 規則

  1. @keyframes my 
  2. from {background: red;} 
  3. to {background: yellow;} 
  4.  
  5. @-moz-keyframes my /* Firefox */ 
  6. from {background: red;} 
  7. to {background: yellow;} 
  8.  
  9. @-webkit-keyframes my /* Safari 和 Chrome */ 
  10. from {background: red;} 
  11. to {background: yellow;} 
  12.  
  13. @-o-keyframes my /* Opera */ 
  14. from {background: red;} 
  15. to {background: yellow;} 

為了豐富元素的變化過程,你可以把from to改為百分比的樣子:

  1. @keyframes my 
  2. 0%   {background: red;} 
  3. 25%  {background: yellow;} 
  4. 50%  {background: blue;} 
  5. 100% {background: green;} 
  6.  
  7. @-moz-keyframes my /* Firefox */ 
  8. 0%   {background: red;} 
  9. 25%  {background: yellow;} 
  10. 50%  {background: blue;} 
  11. 100% {background: green;} 
  12.  
  13. @-webkit-keyframes my /* Safari 和 Chrome */ 
  14. 0%   {background: red;} 
  15. 25%  {background: yellow;} 
  16. 50%  {background: blue;} 
  17. 100% {background: green;} 
  18.  
  19. @-o-keyframes my /* Opera */ 
  20. 0%   {background: red;} 
  21. 25%  {background: yellow;} 
  22. 50%  {background: blue;} 
  23. 100% {background: green;} 

定義好了,接下來我們就可以啟動我們的動畫了。

2).animation啟動動畫效果

  1. div 
  2. animation-name: my; 
  3. animation-duration: 5s; 
  4. animation-timing-function: linear; 
  5. animation-delay: 2s; 
  6. animation-iteration-count: infinite; 
  7. animation-direction: alternate; 
  8. animation-play-state: running; 
  9. /* Firefox: */ 
  10. -moz-animation-name: my; 
  11. -moz-animation-duration: 5s; 
  12. -moz-animation-timing-function: linear; 
  13. -moz-animation-delay: 2s; 
  14. -moz-animation-iteration-count: infinite; 
  15. -moz-animation-direction: alternate; 
  16. -moz-animation-play-state: running; 
  17. /* Safari 和 Chrome: */ 
  18. -webkit-animation-name: my; 
  19. -webkit-animation-duration: 5s; 
  20. -webkit-animation-timing-function: linear; 
  21. -webkit-animation-delay: 2s; 
  22. -webkit-animation-iteration-count: infinite; 
  23. -webkit-animation-direction: alternate; 
  24. -webkit-animation-play-state: running; 
  25. /* Opera: */ 
  26. -o-animation-name: my; 
  27. -o-animation-duration: 5s; 
  28. -o-animation-timing-function: linear; 
  29. -o-animation-delay: 2s; 
  30. -o-animation-iteration-count: infinite; 
  31. -o-animation-direction: alternate; 
  32. -o-animation-play-state: running; 
  33.  
  34. animation-name                   選擇器的 keyframes 的名稱 
  35. animation-duration               動畫所花費的時間 
  36. animation-timing-function        勻速播放動畫 
  37. animation-delay           動畫過多久開始 
  38. animation-iteration-count        播放動畫次數 
  39. animation-direction       是否在下一周期逆向地播放 normal 正常播放  alternate 輪流反向播放 
  40. animation-play-state             暫停動畫  paused 動畫已暫停  running 動畫正在播放 
  41. animation-fill-mode 
  42. none         不填充 
  43. forwards     當動畫完成后,保持最后一個屬性值 
  44. backwards     在animation-delay 所指定的一段時間內,在動畫顯示之前,應用開始屬性值 
  45. both        向前和向后填充模式都被應用。 

參考文檔:W3C官方文檔(CSS篇)

總結
這篇文章主要介紹了CSS樣式更改篇中的過度和動漫基礎知識,希望讓大家對CSS樣式更改有個簡單的認識和了解。

責任編輯:姜華 來源: IT共享之家
相關推薦

2020-10-23 08:51:55

CSS

2020-10-26 13:40:00

CascadingSt

2010-09-14 15:04:42

list-styleCSS

2024-09-23 09:20:02

calc-sizeCSS前端

2023-02-06 09:31:17

CSSJS 動態

2025-05-30 03:20:00

2024-03-28 09:11:24

CSS3TransitionCSS屬性

2021-05-21 07:41:15

Vue 過渡動畫

2023-04-14 16:45:21

CSS前端CSS3

2013-01-30 15:59:29

adobeCSS3HTML5

2023-11-20 09:27:28

CSS前端

2017-07-20 11:11:39

前端CSS書寫規范

2022-03-30 14:34:21

鴻蒙HarmonyOScss

2010-09-13 13:44:35

CSS表格CSS表單

2022-12-28 08:16:30

CSS新規范樣式

2009-04-08 10:51:59

Windows Emb

2010-06-03 16:32:09

Hadoop MapR

2011-07-29 14:55:25

iPhone開發 動畫過渡

2015-08-03 11:42:27

Swift漢堡式過度動畫

2023-07-14 07:52:37

CSS優先級Design
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 四虎最新地址 | 中文字幕1区2区3区 日韩在线视频免费观看 | 日韩欧美操 | 99精品免费| 久久精品国产久精国产 | 久久大| 在线观看www| 亚洲精品视频一区二区三区 | 欧美成人自拍 | 色成人免费网站 | 亚洲国产中文字幕 | 亚洲国产成人av好男人在线观看 | 久久精品亚洲精品国产欧美 | 国产成人精品一区二区三区 | 欧美激情视频一区二区三区在线播放 | 亚洲欧美日韩精品久久亚洲区 | 亚洲啊v在线 | 欧美一级特黄aaa大片在线观看 | 国产免费va | 天天躁日日躁性色aⅴ电影 免费在线观看成年人视频 国产欧美精品 | 一级片成人 | 欧美888| 精品国产亚洲一区二区三区大结局 | 免费在线看黄 | 91国内外精品自在线播放 | 日韩福利| 久久久久免费精品国产小说色大师 | 精品欧美一区二区三区久久久小说 | 女同久久另类99精品国产 | 欧美激情区| 久久久久久av | 欧美jizzhd精品欧美巨大免费 | 91久久精品日日躁夜夜躁欧美 | 自拍偷拍在线视频 | 国产你懂的在线观看 | 玖玖视频国产 | 欧美自拍第一页 | 久久一区二区免费视频 | 久久精品网 | www.日韩| 最新中文字幕在线 |