TShopping
標題:
CSS3中Transitions屬性的使用方法
[打印本頁]
作者:
woff
時間:
2013-3-2 20:11
標題:
CSS3中Transitions屬性的使用方法
在CSS 3中,Transitions功能通過將元素的某個屬性從一個屬性值在指定時間內平滑過渡到另一個屬性值來實現動畫功能。可通過transtions屬性來使用Transtions功能。
j1.png
(3.54 KB, 下載次數: 5)
下載附件
保存到相冊
2013-3-3 16:23 上傳
transtions屬性的使用方法如下所示:
transtion:property duration timing-function其中property表示屬性進行平滑過渡,duraton表示在多長時間內完成屬性值的平滑過渡,tinming-function表示通過什麼方法來進行平滑過渡。
div { width:120px; height:90px; background:blue; transition:background-color 2s linear; }
div:hover { background:orange; }
複製代碼
上面的實例中,把div元素的藍色背景在2秒鐘之內平滑過渡到橙色背景。
當然還有另外一種使用Transitions功能的方法,就是將Transitions屬性中的參數分開來寫,例如下面的代碼:
transtion-property:backgroud-color;
transtion-duration:1s;
tarnstion-timing-function:linear;
複製代碼
使用Transitions功能同時對於多個屬性值進行平滑過渡:
div {
height:90px; background:blue;
width:120px;
-moz-transition:background-color 1s linear,height 1s linear;
}
div:hover {
background:orange;
height:240px;
}
複製代碼
上面的實例中,元素從背景為藍色、高度為120像素平滑過渡到背景為橙色,高度為240像素。
使用Transitions功能實現元素的移動與旋轉動畫:
img {
position:absolute;
top:270px;
left:10px;
-moz-transform:rotate(0deg);
-moz-transition:left 5s linear,-moz-transform 1s linear;
}
img:hover {
left:230px;
-moz-transform:rotate(15deg);
}
複製代碼
上面的實例中,使定位圖片元素從距左邊距10像素、旋轉角度為0狀態平滑過渡到距左邊距230像素、旋轉15度。
作者:
www.dulady.com
時間:
2014-2-7 15:54
看过必回,人品超好!
etsy baby
歡迎光臨 TShopping (http://www.tshopping.com.tw/)
Powered by Discuz! X3.2