I'm trying to animate a div so that when the page load it has scale(0,0) and animates to scale(1,1). The problem I have is that once the animation takes effect the div scales to 0 again. What I want is the div to animate to scale(1,1) and staying like that. Here's my CSS code
@-moz-keyframes bumpin {
0% { -moz-transform: scale(0,0); }
100% { -moz-transform: scale(1,1); }
}
.landing .board {
-moz-transform: scale(0,0);
-moz-transform-origin: 50% 50%;
}
.landing .board {
-moz-animation-name: bumpin;
-moz-animation-duration: 1s;
-moz-animation-timing-function: ease;
-moz-animation-delay: 0s;
-moz-animation-iteration-count: 1;
-moz-animation-direction: normal;
}
What am I doing wrong?
Thanks in advance
Mauro
The scale() CSS function defines a transformation that resizes an element on the 2D plane. Because the amount of scaling is defined by a vector, it can resize the horizontal and vertical dimensions at different scales. Its result is a <transform-function> data type.
Passing a single argument to the scale() function changes the size of an element uniformly, scaling both the height and width by the same amount.
You're looking for animation-fill-mode:forwards
which applies the last keyframe of the nimation to the element when the animation is done. https://developer.mozilla.org/en/CSS/animation-fill-mode
-moz-animation-fill-mode: forwards
Another way of doing this: If all you want to do is animate an element to scale, you don't need to use keyframes. transitions will suffice.
.landing-board {
-moz-transition: all 1s ease;
/* all other css properties */
}
.landing-board.animated {
-moz-transform: scale(1.1);
}
And very little javascript to add the related class to your element: (Here i'm using jquery but it could be done in any other framework or pure javascript)
$(window).load(function() {
$('.landing-board').addClass('animated');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With