標籤:c style class blog code java
瀏覽器支援:
Internet Explorer 10、Firefox 以及 Opera 支援 animation 屬性。
Safari 和 Chrome 支援替代的 -webkit-animation 屬性。
注釋:Internet Explorer 9 以及更早的版本不支援 animation 屬性。
樣本:
<!DOCTYPE html><html><head><style> div{width:100px;height:100px;background:red;position:relative;animation:mymove 5s infinite;-moz-animation:mymove 5s infinite; /* Firefox */-webkit-animation:mymove 5s infinite; /* Safari and Chrome */-o-animation:mymove 5s infinite; /* Opera */}@keyframes mymove{from {top:0px;}to {top:200px;}}@-moz-keyframes mymove /* Firefox */{from {top:0px;}to {top:200px;}}@-webkit-keyframes mymove /* Safari and Chrome */{from {top:0px;}to {top:200px;}}@-o-keyframes mymove /* Opera */{from {top:0px;}to {top:200px;}}</style></head><body><p><b>注釋:</b>本例在 Internet Explorer 中無效。</p><div></div></body></html>
文法:
animation: name duration timing-function delay iteration-count direction;
| 值 |
描述 |
| animation-name |
規定需要綁定到選取器的 keyframe 名稱。 |
| animation-duration |
規定完成動畫所花費的時間,以秒或毫秒計。
(註:預設時間長度為 0,不會播放動畫了) |
| animation-timing-function |
規定動畫的速度曲線。 |
| animation-delay |
規定在動畫開始之前的延遲。 |
| animation-iteration-count |
規定動畫應該播放的次數。 |
| animation-direction |
規定是否應該輪流反向播放動畫。 |