Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Animation property stays after animating

I'm trying to get a CSS animation property to stay after completing, is this possible?

This is what I'm trying to achieve...

The element should be hidden when the user lands on the page, after 3 seconds (or whatever), it should fade in and once the animation has completed it should stay there.

Here is a fiddle attempt... http://jsfiddle.net/GZx6F/

Here is the code for preservation...

<h2>Test</h2>  <style> @keyframes fadeIn {     0% {         opacity: 0;     }     100% {         opacity: 0.9;     } }  h2 {     animation: fadeIn 1s ease-in-out 3s; } </style> 

I know how to do this with jQuery.. it would be like this...

<h2>test</h2>  <script>   $(document).ready(function(){     $('h2').hide().delay(3000).fadeIn(3000)   }); </script> 
like image 497
SparrwHawk Avatar asked Mar 19 '12 17:03

SparrwHawk


People also ask

How do you make an object stay after animation?

Try turning off the animation looping option in the animation editor. It should be a circular arrow icon that is highlighted blue. It seems you have an animation loop on, you would have to turn it off in order to make it stay in its place, it should be somewhere around the pause/play button, you won't miss it.

What CSS property ensures the animation stays in the end position after the animation finishes?

The animation-fill-mode property specifies a style for the element when the animation is not playing (before it starts, after it ends, or both).

How do I animate persist in CSS?

Use animation-fill-mode: forwards; The element will retain the style values that is set by the last keyframe (depends on animation-direction and animation-iteration-count).


1 Answers

I think you're looking for animation-fill-mode CSS3 property

https://developer.mozilla.org/en/CSS/animation-fill-mode

The animation-fill-mode CSS property specifies how a CSS animation should apply styles to its target before and after it is executing.

for your purpose just try to set

h2 {   animation: fadeIn 1s ease-in-out 3s;   animation-fill-mode: forwards;   } 

Setting forwards value «the target will retain the computed values set by the last keyframe encountered during execution»

like image 62
Fabrizio Calderan Avatar answered Oct 25 '22 18:10

Fabrizio Calderan