.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;
}
}
Dynamically switch to this style for an element and want it to stay on the last frame. But it doesn’t work
Remove the
webkit
prefix and modify it as follows:Since the animation attribute works, it means that the related attributes do not need to be prefixed in this browser.
animation
is a comprehensive attribute. The defaultanimation-fill-mode
isnone
. Using the prefixed attributewebkit-animation-fill-mode
cannot overrideanimation-fill-mode
, so you need to Remove the prefix.Thanks for the invitation,
@luckness has made it very clear.
In addition, prefixes such as webkit are to be compatible with different versions of different browsers.
A more conservative way of writing it can be: