CSS 參考手冊

CSS @規(guī)則(RULES)

CSS 屬性大全

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

CSS3 animation-fill-mode屬性指定CSS動畫在執(zhí)行之前和之后,如何將樣式應用于其目標。

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

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

animation-fill-mode的使用語法

該屬性的語法如下:

animation-fill-mode: none | forwards | backwards | both | initial | inherit

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

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

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

屬性值

下表描述了此屬性的值。

描述
none動畫在執(zhí)行之前或之后不會對目標應用任何樣式。
forwards動畫結束后(由決定animation-iteration-count),動畫將在動畫結束時應用屬性值。
backwards動畫將應用在關鍵幀中定義的屬性值,該關鍵幀將由animation-delay屬性定義的時間段內(nèi)開始動畫的第一次迭代。這些是from關鍵幀的值(animation-direction為normal或時alternate)或to關鍵幀的值(animation-direction為reverse或時alternate-reverse)。
both動畫將遵循向前和向后的規(guī)則,從而在兩個方向上擴展了動畫屬性。
initial將此屬性設置為其默認值。
inherit如果指定,則關聯(lián)元素采用其父元素animation-fill-mode屬性的計算值。

瀏覽器兼容性

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

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

  • Google Chrome 4+ -webkit-

  • Internet Explorer 10+

  • Apple Safari 4+ -webkit-

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

進一步閱讀

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

相關屬性和規(guī)則:   animation,animation-name,animation-duration,animation-timing-functionanimation-delay,animation-iteration-countanimation-direction,animation-play-state,@keyframes

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