javascript - 為什么我的animation-fill-mode 設(shè)置不生效
問題描述
.gold_egg_broken{
background: url('../img/animation/goldeggBroke.png');width: 400px;height: 400px;animation: eggbroken 3s;-webkit-animation-fill-mode:forwards;-webkit-animation-timing-function: steps(80);
}
@-webkit-keyframes eggbroken {
0%{ background-position: 0 0;}90%{ background-position: 0 -32000px;}100%{ background-position: 0 -32000px;}
}
動態(tài)切換給一個元素這個樣式 想讓它停留在最后一幀保持不動。但是不生效
問題解答
回答1:把webkit前綴去掉,修改如下:
.gold_egg_broken{ background: url('../img/animation/goldeggBroke.png'); width: 400px; height: 400px; animation: eggbroken 3s; animation-fill-mode:forwards; animation-timing-function: steps(80);}
既然animation屬性起作用了,那么也就是說在該瀏覽器中相關(guān)屬性不需要前綴了。animation是一個綜合屬性,默認的animation-fill-mode是none,使用帶前綴的屬性webkit-animation-fill-mode不能覆蓋掉animation-fill-mode,所以需要把前綴去掉。
回答2:謝邀,@luckness 已經(jīng)說的很明白。另外就是 webkit 這類前綴是為了兼容不同瀏覽器的不同版本的,保守一點的寫法可以是:
p{ -webkit-animation-fill-mode: forwards;-moz-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; animation-fill-mode: forwards;}
相關(guān)文章:
1. mysql - AttributeError: ’module’ object has no attribute ’MatchType’2. github - 利用Python 自動化部署問題3. 求大神幫我看看是哪里寫錯了 感謝細心解答4. npm鏡像站全新上線5. javascript - 圖片能在網(wǎng)站顯示,但控制臺仍舊報錯403 (Forbidden)6. python - from ..xxxx import xxxx到底是什么意思呢?7. php自學從哪里開始?8. MySQL客戶端吃掉了SQL注解?9. phpstady在win10上運行10. 數(shù)據(jù)庫 - MySQL 單表500W+數(shù)據(jù),查詢超時,如何優(yōu)化呢?
