JOIN OVER 31,000HAPPY CUSTOMERS AND GET ACCESS TO OUR FULL COLLECTION OF SENSATIONAL THEMES - 33 FOR THE PRICE OF ONE!

CSS3 Tricks: Falling Leaves Animation with CSS only

In today’s tutorial, we will create Falling leaves animation effect without any help of javascript. When I started playing with CSS3 I never thought that I could make such fascinating animations with it. I made falling leaves animation in both Flash and Javascript but I never thought that it is possible to make it with CSS3 only. While it is not as cool as the Flash one, it is still fairly decent and it uses less CPU. I recommend that you download the source files first and check the live demo. If you’d like to print these instructions as a reference, ordering new ink online is the easiest route – the best ink providers also offer toner cartridge recycling free of charge to all customers.

Add the leaf here as a background for each instance of span that we defined earlier. Size and initial position of the leaves is set here. Webkit animation is actually pretty simple. We set which class to animate (fallingLeaves) and set the falling time to 10 seconds. We want the animation to continuously repeat itself so we will set it to infinite. Eeasing is set to linear to achieve a smooth falling effect.

Before we get to the animation effect we have to somehow randomize the leaves so they don’t all start falling at the same time. I used the nth-child method to define several sequences of leaves with different animation delays.

These are just three examples, I added several more sequences in the live example provided above. Download the source files to see them all. First sequence is set to 5n+5 which means leaves number 5, 10, 15,… will start falling with the delay of 1 second. Second sequence is set to 3n + 2 which means leaves 2,5, 8, 11,… will start falling with the delay of 1.5 second. Note that some sequences may overlap with each other but it’s not a big deal, the css will always take the last setting and use it for the animation.

IF YOU LIKE LIST ANIMATION YOU CAN ALSO CHECK OUR wORDPRESS THEME WITH RAIN ANIMATION

We are proud to present our fresh new WordPress theme: Raindrop. It is a multipurpose and flexible theme that offers you an almost unlimited variety of unique page layouts. We recently developed a free WordPress Blog Theme that I believe would be a nice start to your blogging journey.

SETTING UP THE LEAVES ANIMATION

All we have to add now is the animation effect. It is actually pretty simple. Add the following code to your style.css file:

As you can see we divided our animation into three parts (state at 0%, at 75% and at 100%). Animation starts with x and y coordinates set to 0px and rotation along Z axis also set to 0. This is the initial position of the animation. After the animation starts it will start moving towards position set in the second part (75%). Leaves will move slightly to the right (x coordinate is set to 100px) and down (y coordinate is set to 600px). It will also rotate for 3/4 of the full circle (270deg). Leaves will still be fully visible (opacity is set to 1). Opacity is the reason why we added the second part of animation anyway. It allows us to slowly fade the leaves to invisible after they reach a certain point. When leaves reach the ending point (100%) they are instantly moved back up where they start animating again. And we are done. The implementation is pretty simple and straightforward and you get a decent falling leaves effect in no time.

CONCLUSION

CSS3 animations can be very powerful and diverse and even animation of multiple objects is a piece of cake. Please note that these animations are only supported in webkit browsers (Chrome, Opera). In our future tips&tricks posts I will show you how to make gradients, apply animations to images and much more so stay tuned!

MARKET FOR CREATIVES

OPTIN MONSTER NEWSLETTER

Our Sponsors

Popular posts

OUR NEWSLETTER

Subscribe to our newsletter to receive news, updates, freebies and new WordPress Themes releases by email. We never spam.

Enter your email address...

Premiumcoding offers premium WordPress themes for corporate and personal use. From clean and minimal, to complex and multi-functional, every one of our themes is professional, responsive and beautiful.