javascript - 為什么我的animation-fill-mode 設置不生效
問題描述
.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;}
}
動態切換給一個元素這個樣式 想讓它停留在最后一幀保持不動。但是不生效
問題解答
回答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屬性起作用了,那么也就是說在該瀏覽器中相關屬性不需要前綴了。animation是一個綜合屬性,默認的animation-fill-mode是none,使用帶前綴的屬性webkit-animation-fill-mode不能覆蓋掉animation-fill-mode,所以需要把前綴去掉。
回答2:謝邀,@luckness 已經說的很明白。另外就是 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;}
相關文章:
1. mac OSX10.12.4 (16E195)下Mysql 5.7.18找不到配置文件my.cnf2. mysql - 怎么生成這個sql表?3. mysql儲存json錯誤4. php - 公眾號文章底部的小程序二維碼如何統計?5. mysql - 表名稱前綴到底有啥用?6. mysql - 數據庫表中,兩個表互為外鍵參考如何解決7. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?8. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?9. mysql - 數據庫建字段,默認值空和empty string有什么區別 11010. sql語句 - 如何在mysql中批量添加用戶?
