一、transform 用來定義變換 IE10及以上支持css
示例:transform: rotate | scale | skew | translate |matrix;html
1、旋轉rotate 正數表示順時針旋轉,若是設置的值爲負數,則表示逆時針旋轉web
2、移動translate動畫
移動translate咱們分爲三種狀況:translate(x,y)水平方向和垂直方向同時移動(也就是X軸和Y軸同時移動)ssr
3、縮放scaleorm
具備三種狀況:scale(x,y)使元素水平方向和垂直方向同時縮放(也就是X軸和Y軸同時縮放);scaleX(x)元素僅水平方向縮放(X軸縮放);scaleY(y)元素僅垂直方向縮放(Y軸縮放),但它們具備相同的縮放中心點和基數,其中心點就是元素的中心位置,縮放基數爲1,若是其值大於1元素就放大,反之其值小於1,元素縮小htm
scale(<number>[, <number>]):提供執行[sx,sy]縮放矢量的兩個參數指定一個2D scale(2D縮放)。若是第二個參數未提供,則取與第一個參數同樣的值。
對象
4、扭曲skewblog
skew(x,y)使元素在水平和垂直方向同時扭曲(X軸和Y軸同時按必定的角度值進行扭曲變形);skewX(x)僅使元素在水平方向扭曲變形(X軸扭曲變形);skewY(y)僅使元素在垂直方向扭曲變形(Y軸扭曲變形)get
skew(<angle> [, <angle>]) :X軸Y軸上的skew transformation(斜切變換)。第一個參數對應X軸,第二個參數對應Y軸。若是第二個參數未提供,則值爲0,也就是Y軸方向上無斜切
5、矩陣matrix
matrix(<number>, <number>, <number>, <number>, <number>, <number>) : 以一個含六值的(a,b,c,d,e,f)變換矩陣的形式指定一個2D變換,至關於直接應用一個[a b c d e f]變換矩陣。就是基於水平方向(X軸)和垂直方向(Y軸)從新定位元素
二、animate 動畫與div綁定
div { animation: myfirst 5s; -moz-animation: myfirst 5s; /* Firefox */ -webkit-animation: myfirst 5s; /* Safari 和 Chrome */ -o-animation: myfirst 5s; /* Opera */ }
動畫定義(百分比)
@keyframes myfirst { 0% {background: red;} 25% {background: yellow;} 50% {background: blue;} 100% {background: green;} } @-moz-keyframes myfirst /* Firefox */ { 0% {background: red;} 25% {background: yellow;} 50% {background: blue;} 100% {background: green;} } @-webkit-keyframes myfirst /* Safari 和 Chrome */ { 0% {background: red;} 25% {background: yellow;} 50% {background: blue;} 100% {background: green;} } @-o-keyframes myfirst /* Opera */ { 0% {background: red;} 25% {background: yellow;} 50% {background: blue;} 100% {background: green;} }
動畫定義(from 和 to)
@keyframes myfirst { from {background: red;} to {background: yellow;} } @-moz-keyframes myfirst /* Firefox */ { from {background: red;} to {background: yellow;} } @-webkit-keyframes myfirst /* Safari 和 Chrome */ { from {background: red;} to {background: yellow;} } @-o-keyframes myfirst /* Opera */ { from {background: red;} to {background: yellow;} }
全部動畫的屬性
屬性 | 描述 | 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 |
定義全部屬性
div { animation-name: myfirst; animation-duration: 5s; animation-timing-function: linear; animation-delay: 2s; animation-iteration-count: infinite; animation-direction: alternate; animation-play-state: running; /* Firefox: */ -moz-animation-name: myfirst; -moz-animation-duration: 5s; -moz-animation-timing-function: linear; -moz-animation-delay: 2s; -moz-animation-iteration-count: infinite; -moz-animation-direction: alternate; -moz-animation-play-state: running; /* Safari 和 Chrome: */ -webkit-animation-name: myfirst; -webkit-animation-duration: 5s; -webkit-animation-timing-function: linear; -webkit-animation-delay: 2s; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; -webkit-animation-play-state: running; /* Opera: */ -o-animation-name: myfirst; -o-animation-duration: 5s; -o-animation-timing-function: linear; -o-animation-delay: 2s; -o-animation-iteration-count: infinite; -o-animation-direction: alternate; -o-animation-play-state: running; }
簡寫的定義
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; }