How to use the animation-fill-mode attribute in css
This article mainly introduces how to use the animation-fill-mode attribute in css. The article is very detailed and has certain reference value. Interested friends must read it!
CSS3animation-fill-mode property
Effects: The animation-fill-mode property specifies whether animation effects are visible before or after the animation is played.
Description: By default, CSS animations don't affect elements until the first keyframe is played, and stop affecting elements after the last keyframe is complete. The animation-fill-mode property overrides this behavior.
Grammar:
animation-fill-mode:none|forwards|backwards|both;
None: Does not change default behavior.
forwards: Keep the last attribute value (defined in the last keyframe) when the animation is complete.
backwards: Apply the start attribute value (defined in the first keyframe) before the animation is displayed for the period specified by animation-delay.
Both: Forward and backward fill modes are applied.
Note: Internet Explorer 9 and earlier versions do not support the animation-fill-mode attribute.
CSS3Animation-fill-mode attribute usage example
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove3s;
animation-iteration-count:2;
animation-fill-mode:forwards;
Safari and Chrome*/
-webkit-animation:mymove3s;
-webkit-animation-iteration-count:2;
-webkit-animation-fill-mode:forwards;
}
@keyframesmymove
{
from{top:0px;}
to{top:200px;}
}
@-webkit-keyframesmove/*Safari and Chrome*/
{
from{top:0px;}
to{top:200px;}
}
The above is "how to use animation-fill-mode attribute in css" all the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!