CSS 參考手冊

CSS @規(guī)則(RULES)

CSS 屬性大全

CSS3 animation-direction 屬性使用方法及示例

CSS animation-direction屬性指定動畫是否應在交替的循環(huán)中反向播放。

下表總結了此屬性的用法上下文和版本歷史記錄。

默認值:normal
適用于:所有元素::before和::after 偽元素
繼承:沒有
可動畫制作:否。請參見 動畫屬性
版本: CSS3的新功能
JavaScript 語法:object.style.animationDirection="reverse"

animation-direction的使用語法

該屬性的語法如下:

animation-direction: normal | reverse | alternate | alternate-reverse | initial | inherit

下面的示例演示了如何使用animation-direction屬性。

.box {
    width: 50px;
    height: 50px;
    background: red;
    position: relative;
    /* Chrome, Safari, Opera */
    -webkit-animation-name: moveit;
    -webkit-animation-duration: 4s;
    -webkit-animation-iteration-count: 2;
    -webkit-animation-direction: alternate;
    
    animation-name: moveit;
    animation-duration: 4s;
    animation-iteration-count: 2;
    animation-direction: alternate;
}
 
/* Chrome, Safari, Opera */
@-webkit-keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}
 

@keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}
測試看看?/?

注意:如果將動畫設置為僅播放一次,則animation-direction該屬性無效,請參見animation-iteration-count屬性。

屬性值

下表描述了此屬性的值。

描述
normal動畫應在每個周期中播放。這是默認值。
reverse動畫應在每個循環(huán)中向后播放。
alternate動畫在第一個循環(huán)中向前播放,然后向后播放,然后繼續(xù)交替播放。
alternate-reverse動畫在第一個循環(huán)中向后播放,然后向前播放,然后繼續(xù)交替播放。
initial將此屬性設置為其默認值。
inherit如果指定,則關聯(lián)元素采用其父元素屬性的計算值animation-direction。

瀏覽器兼容性

animation-direction屬性瀏覽器的兼容性,所有主流瀏覽器均支持該屬性。

瀏覽器圖標
  • Firefox 5+ -moz-,15 +

  • Google Chrome 4+ -webkit-

  • Internet Explorer 10+

  • Apple Safari 4+ -webkit-

  • Opera 12+ -o-,15+ -webkit-

進一步閱讀

請參考以下教程:CSS3動畫。

相關屬性和規(guī)則:animation,animation-nameanimation-delay,animation-timing-function,animation-iteration-count,animation-directionanimation-fill-mode,animation-play-state@keyframes。

丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清