{"id":6146,"date":"2017-01-30T19:31:47","date_gmt":"2017-01-30T19:31:47","guid":{"rendered":"http:\/\/premiumcoding.com\/?p=6146"},"modified":"2019-09-24T04:20:53","modified_gmt":"2019-09-24T04:20:53","slug":"css3-tricks-falling-leaves-css","status":"publish","type":"post","link":"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/","title":{"rendered":"CSS3 Tricks: Falling Leaves Animation with CSS only"},"content":{"rendered":"<p>In today&#8217;s tutorial, we will create <strong>Falling leaves animation<\/strong>\u00a0effect without any help of javascript. When I started playing with <strong>CSS3<\/strong> I never thought that I could make such fascinating animations with it. I made <strong>falling leaves<\/strong> animation in both Flash\u00a0and Javascript but I never thought that it is possible to make it with<strong> CSS3 only<\/strong>. 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&#8217;d like to print these instructions as a reference, ordering new ink online is the easiest route &#8211; the best ink providers <a href=\"http:\/\/www.inktechnologies.com\">also offer toner cartridge recycling free<\/a> of charge to all customers.<\/p>\n<p>I also just prepared a <strong><a href=\"https:\/\/premiumcoding.com\/css3-tricks-falling-snow-css\/\">Falling Snow CSS Animation<\/a><\/strong> for winter is coming. \ud83d\ude42<\/p>\n<p>We just developed our own <strong>free<\/strong> version of the <a href=\"https:\/\/premiumcoding.com\/falling-snow-leaves-free-wordpress-plugin\/\"><strong>Falling snow \/ leaves WordPress Plugin<\/strong><\/a>.<\/p>\n<h3>LIVE DEMO<\/h3>\n<p><div class=\"buttonshort\"><div class=\"buttondark\"><div class=\"buttonleft\"><a  href=\"http:\/\/premiumcoding.com\/CSSTricks\/fallingLeaves\/\" target=\"_blank\">CSS3 Falling Leaves Preview!<\/a><\/div><\/div><\/div><br \/>\n<a class=\"manual-optin-trigger\" href=\"https:\/\/app.monstercampaigns.com\/c\/kwbyysb68mwpabgbtoli\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-optin-slug=\"kwbyysb68mwpabgbtoli\">Download Falling Leaves Source Files<\/a><\/p>\n<h3>SETTING UP THE LEAVES<\/h3>\n<p>We add one instance of the leaf with the &lt;span&gt;&lt;\/span&gt; tag. If you wish to add more leaves simply multiply this tag. Now create a file style.css and add the design for the class created above:<br \/>\n<div class=\"pmc-code\"><br \/>\n.fallingLeaves span {<br \/>\ndisplay: inline-block;<br \/>\nwidth: 80px;<br \/>\nheight: 80px;<br \/>\nmargin: -280px 40px 54px -34px;<\/p>\n<p>background:url(&#8220;leaf.png&#8221;);<\/p>\n<p>-webkit-animation: fallingLeaves 10s infinite linear;<br \/>\n-moz-animation: fallingLeaves 10s infinite linear;<br \/>\n}<br \/>\n<\/div><br \/>\nAdd 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. <strong>Webkit animation<\/strong> is actually pretty simple. We set which class to animate (<strong>fallingLeaves<\/strong>) and set the falling time to 10 seconds. We want the animation to continuously\u00a0repeat itself so we will set it to <strong>infinite<\/strong>. Eeasing is set to linear to achieve a smooth falling effect.<\/p>\n<p>Before we get to the animation effect we have to somehow randomize the leaves so they don&#8217;t all start falling at the same time. I used the\u00a0nth-child method to define several sequences of leaves with different animation delays.<br \/>\n<div class=\"pmc-code\"><br \/>\n.fallingLeaves span:nth-child(5n+5) {<br \/>\n-webkit-animation-delay: 1s;<br \/>\n-moz-animation-delay: 1s;<br \/>\n}<\/p>\n<p>.fallingLeaves span:nth-child(3n+2) {<br \/>\n-webkit-animation-delay: 1.5s;<br \/>\n-moz-animation-delay: 1.5s;<br \/>\n}<\/p>\n<p>.fallingLeaves span:nth-child(2n+5) {<br \/>\n-webkit-animation-delay: 1.7s;<br \/>\n-moz-animation-delay: 1.7s;<br \/>\n}<br \/>\n<\/div><\/p>\n<p><div class=\"buttonshort\"><div class=\"buttondark\"><div class=\"buttonleft\"><a  href=\"https:\/\/premiumcoding.com\/premiumcoding-wordpress-themes\/\" target=\"_blank\">Check Our WordPress Themes<\/a><\/div><\/div><\/div><br \/>\nThese are just three examples, I added several more sequences in the <strong><a title=\"CSS3 Falling leaves\" href=\"http:\/\/premiumcoding.com\/CSSTricks\/fallingLeaves\/\">live example<\/a><\/strong> provided above. Download the source files to see them all. First sequence is set to 5n+5 which means leaves number 5, 10, 15,&#8230; will start falling with the delay of 1 second. Second sequence is set to 3n + 2 which means leaves 2,5, 8, 11,&#8230; will start falling with the delay of 1.5 second. Note that some sequences may overlap with each other but it&#8217;s not a big deal, the css will always take the last setting and use it for the animation.<\/p>\n<h3>Unlimited WordPress Themes &amp; Plugins From $16.5<\/h3>\n<p><a href=\"https:\/\/1.envato.market\/GdgyB\"><img loading=\"lazy\" class=\"aligncenter wp-image-725782 size-large\" src=\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/og-default-1024x538.jpg\" rel=\"lightbox[6146]\" alt=\"\" width=\"800\" height=\"420\" srcset=\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/og-default-1024x538.jpg 1024w, https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/og-default-300x158.jpg 300w, https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/og-default-768x403.jpg 768w, https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/og-default.jpg 1200w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><br \/>\n<img loading=\"lazy\" style=\"position: absolute; visibility: hidden;\" src=\"\/\/constant-contact.evyy.net\/i\/1325303\/418615\/3411\" width=\"0\" height=\"0\" border=\"0\" \/><\/p>\n<h3>IF YOU LIKE LIST ANIMATION YOU CAN ALSO CHECK OUR WORDPRESS THEME WITH RAIN ANIMATION<\/h3>\n<p><a href=\"http:\/\/landingraindrops.premiumcoding.com\/demo.php\"><img loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2012\/04\/raindrops-multipurpose-wordpress-theme-11.png\" rel=\"lightbox[6146]\" alt=\"CSS Falling Leaves Animation Example\" width=\"797\" height=\"478\" \/><\/a><\/p>\n<p>We are proud to present our fresh new WordPress theme: <a href=\"https:\/\/premiumcoding.com\/wordpress-themes\/raindrops-wordpress-theme\/\"><strong>Raindrop<\/strong><\/a>. 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 <a href=\"https:\/\/premiumcoding.com\/everly-lite-free-hipster-wordpress-blog-theme\/\">blogging journey<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h3>SETTING UP THE LEAVES ANIMATION<\/h3>\n<p>All we have to add now is the animation effect. It is actually pretty simple. Add the following code to your style.css file:<br \/>\n<div class=\"pmc-code\"><br \/>\n@-webkit-keyframes fallingLeaves {<br \/>\n0% {<br \/>\nopacity: 1;<br \/>\n-webkit-transform: translate(0, 0px) rotateZ(0deg);<br \/>\n}<br \/>\n75% {<br \/>\nopacity: 1;<br \/>\n-webkit-transform: translate(100px, 600px) rotateZ(270deg);<br \/>\n}<br \/>\n100% {<br \/>\nopacity: 0;<br \/>\n-webkit-transform: translate(150px, 800px) rotateZ(360deg);<br \/>\n}<br \/>\n}<br \/>\n<\/div><br \/>\nAs 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<strong> fade the leaves<\/strong> to<strong> invisible<\/strong> 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.<\/p>\n<h3>CONCLUSION<\/h3>\n<p>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&amp;tricks posts I will show you how to make gradients, apply animations to images and much more so stay tuned!<\/p>\n<p><a class=\"manual-optin-trigger\" href=\"https:\/\/app.monstercampaigns.com\/c\/kwbyysb68mwpabgbtoli\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-optin-slug=\"kwbyysb68mwpabgbtoli\">Download Falling Leaves Source Files<\/a><\/p>\n<div class=\"buttonshort\"><div class=\"buttondark\"><div class=\"buttonleft\"><a  href=\"https:\/\/premiumcoding.com\/premiumcoding-wordpress-themes\/\" target=\"_blank\">Check Our WordPress Themes<\/a><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s tutorial, we will create Falling leaves animation\u00a0effect 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\u00a0and Javascript but I never thought that it is possible to make it with CSS3 only. &#8230;<\/p>\n","protected":false},"author":1,"featured_media":43007,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,178],"tags":[718,731,721],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CSS3 Tricks: Falling Leaves Animation with CSS only - PremiumCoding<\/title>\n<meta name=\"description\" content=\"In today&#039;s tutorial, we will create Falling leaves animation\u00a0effect without any help of javascript. When I started playing with CSS3 I never thought that\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS3 Tricks: Falling Leaves Animation with CSS only - PremiumCoding\" \/>\n<meta property=\"og:description\" content=\"In today&#039;s tutorial, we will create Falling leaves animation\u00a0effect without any help of javascript. When I started playing with CSS3 I never thought that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/\" \/>\n<meta property=\"og:site_name\" content=\"PremiumCoding\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-30T19:31:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-24T04:20:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2017\/01\/css3-tricks-falling-leaves-animation.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"390\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"4 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/premiumcoding.com\/#organization\",\"name\":\"PremiumCoding\",\"url\":\"https:\/\/premiumcoding.com\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/premiumcoding.com\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2013\/12\/premiumcoding-wordpress-themes-logo@2x.png\",\"width\":400,\"height\":134,\"caption\":\"PremiumCoding\"},\"image\":{\"@id\":\"https:\/\/premiumcoding.com\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/premiumcoding.com\/#website\",\"url\":\"https:\/\/premiumcoding.com\/\",\"name\":\"PremiumCoding\",\"description\":\"WordPress Themes, Tutorials &amp; Articles\",\"publisher\":{\"@id\":\"https:\/\/premiumcoding.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/premiumcoding.com\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/premiumcoding.com\/wp-content\/uploads\/2017\/01\/css3-tricks-falling-leaves-animation.jpg\",\"width\":800,\"height\":390,\"caption\":\"css3 tricks falling leaves animation\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#webpage\",\"url\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/\",\"name\":\"CSS3 Tricks: Falling Leaves Animation with CSS only - PremiumCoding\",\"isPartOf\":{\"@id\":\"https:\/\/premiumcoding.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#primaryimage\"},\"datePublished\":\"2017-01-30T19:31:47+00:00\",\"dateModified\":\"2019-09-24T04:20:53+00:00\",\"description\":\"In today's tutorial, we will create Falling leaves animation\\u00a0effect without any help of javascript. When I started playing with CSS3 I never thought that\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#webpage\"},\"author\":{\"@id\":\"https:\/\/premiumcoding.com\/#\/schema\/person\/e82e4a7d2166758ae7c30a69e651b04c\"},\"headline\":\"CSS3 Tricks: Falling Leaves Animation with CSS only\",\"datePublished\":\"2017-01-30T19:31:47+00:00\",\"dateModified\":\"2019-09-24T04:20:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#webpage\"},\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/premiumcoding.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#primaryimage\"},\"keywords\":\"css3 animation,css3 falling leaves,css3 tricks\",\"articleSection\":\"Blog,Tutorials\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/premiumcoding.com\/css3-tricks-falling-leaves-css\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/premiumcoding.com\/#\/schema\/person\/e82e4a7d2166758ae7c30a69e651b04c\",\"name\":\"Ales\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/premiumcoding.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a5b70a6c161b959988486ba65abb4653?s=96&d=wp_user_avatar&r=g\",\"caption\":\"Ales\"},\"sameAs\":[\"https:\/\/premiumcoding.com\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/posts\/6146"}],"collection":[{"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/comments?post=6146"}],"version-history":[{"count":0,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/posts\/6146\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/media\/43007"}],"wp:attachment":[{"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/media?parent=6146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/categories?post=6146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/premiumcoding.com\/wp-json\/wp\/v2\/tags?post=6146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}