你可以通過組合JS和C來完成SS3轉換。
http://jsfiddle.net/hQLQQ/1/
CSS:
#regform {
-webkit-transition:opacity 300ms;
-moz-transition:opacity 300ms;
-o-transition:opacity 300ms;
-ms-transition:opacity 300ms;
}
JS:
var toggle = function(elm){
// check if style property is defined, then read .display, or assume it's "block"
var y=elm.style ? elm.style.display : '';
if (!y || y == 'block'){
// change the opacity. CSS will handle the animation.
elm.style.opacity='0';
// change the display to "none" after a delay.
setTimeout(function(){ elm.style.display = 'none'; }, 300);
}
else {
// change diplay to block. the element is still transparent.
elm.style.display='block';
// set the opacity to 1, CSS will animate it.
// small delay because some browsers won't properly
// animate when changing "display" at the same moment.
setTimeout(function(){ elm.style.opacity = '1'; }, 10);
}
}
爲什麼不使用jQuery? – Vince
我只需要javascript代碼 –
jQuery使用一堆代碼來實現動畫。你將不得不創建你自己的動畫系統。 –