成人免费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

2023-02-06 09:31:17

CSSJS 動態

2024-09-23 09:20:02

calc-sizeCSS前端

2010-09-14 15:04:42

list-styleCSS

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

2011-07-29 14:55:25

iPhone開發 動畫過渡

2015-08-03 11:42:27

Swift漢堡式過度動畫

2022-12-28 08:16:30

CSS新規范樣式

2010-09-13 13:44:35

CSS表格CSS表單

2009-04-08 10:51:59

Windows Emb

2024-03-22 12:22:50

Vue前端

2023-07-14 07:52:37

CSS優先級Design
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产三级精品视频 | 欧美www在线 | 欧美在线一区二区三区 | www国产成人免费观看视频,深夜成人网 | 欧美亚洲免费 | 日韩有码一区 | 天天天操| 国产精品久久国产精品 | 国产在线视频一区二区董小宛性色 | 国产午夜精品理论片a大结局 | 国产精品1区 | 国内久久精品 | 色悠悠久 | www.蜜桃av | av一区二区三区 | 中文字幕日韩在线观看 | 香蕉婷婷 | 日韩精品视频中文字幕 | 日韩一级精品视频在线观看 | 日日干综合 | 亚洲国产成人久久综合一区,久久久国产99 | 国产色 | 成人欧美一区二区三区黑人孕妇 | 日本精a在线观看 | 国产精品久久9 | 国产亚洲www| 黑色丝袜三级在线播放 | 91一区二区三区在线观看 | 巨大黑人极品videos精品 | 黄色精品 | 欧美福利三区 | 一区二区精品电影 | 在线观看成人小视频 | 久久免费高清 | 先锋资源在线 | 天天综合网7799精品 | 欧美一区二区二区 | 成人天堂噜噜噜 | 91麻豆精品国产91久久久久久 | 精品久久久一区 | 91精品国产一区二区三区 |