2012-09-06 30 views
0

如何以下重寫使用變量:如何定義一個用於webkitTransition的常量?

element.style.webkitTransition = "opacity 1.0s ease"; 

我嘗試了這些,但他們沒有工作:

var kDuration = 1.0; 
element.style.webkitTransition = "opacity kDurations ease"; 

var kDuration = 1.0; 
element.style.webkitTransition = "opacity kDuration ease"; 

var kDuration = 1.0; 
element.style.webkitTransition = "opacity kDuration s ease"; 

var kDuration = 1.0; 
element.style.webkitTransition = "opacity kDuration + s ease"; 

var kDuration = 1.0s; 
element.style.webkitTransition = "opacity kDuration ease"; 

回答

0
var kDurationfirst = "1.0s"; var kDuration= "opacity "+kDurationfirst +" ease"; 
element.style.webkitTransition = kDuration ; 
+0

如果我用這則動畫停止工作,它的工作原理如果我恢復到「不透明度1.0s緩解」 – Gruntcakes

+0

嘗試我編輯的一個 –