Плавно падающие фоновые осенние листья на Javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#leafContainer { position: absolute; width: 100%; height: 300px; z-index: -1; } #leafContainer> div { position: absolute; width: 100px; height: 100px; z-index: -1; /* We use the following properties to apply the fade and drop animations to each leaf. Each of these properties takes two values. These values respectively match a setting for fade and drop. */ -webkit-animation-iteration-count: infinite, infinite; -webkit-animation-direction: normal, normal; -webkit-animation-timing-function: linear, ease-in; } /* This CSS rule is applied to all img elements directly inside div elements which are directly inside the leafContainer div. In other words, it matches the 'img' elements inside the leafDivs which are created in the createALeaf() function. */ #leafContainer> div> img { position: absolute; width: 100px; height: 100px; z-index: -1; /* We use the following properties to adjust the clockwiseSpin or counterclockwiseSpinAndFlip animations on each leaf. The createALeaf function in the Leaves.js file determines whether a leaf has the clockwiseSpin or counterclockwiseSpinAndFlip animation. */ -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; -webkit-animation-timing-function: ease-in-out; -webkit-transform-origin: 50% -100%; } /* Hides a leaf towards the very end of the animation */ @-webkit-keyframes fade { /* Show a leaf while into or below 95 percent of the animation and hide it, otherwise */ 0% { opacity: 1; } 95% { opacity: 1; } 100% { opacity: 0; } } /* Makes a leaf fall from -300 to 600 pixels in the y-axis */ @-webkit-keyframes drop { /* Move a leaf to -300 pixels in the y-axis at the start of the animation */ 0% { -webkit-transform: translate(0px, -50px); } /* Move a leaf to 600 pixels in the y-axis at the end of the animation */ 100% { -webkit-transform: translate(0px, 650px); } } /* Rotates a leaf from -50 to 50 degrees in 2D space */ @-webkit-keyframes clockwiseSpin { /* Rotate a leaf by -50 degrees in 2D space at the start of the animation */ 0% { -webkit-transform: rotate(-50deg); } /* Rotate a leaf by 50 degrees in 2D space at the end of the animation */ 100% { -webkit-transform: rotate(50deg); } } /* Flips a leaf and rotates it from 50 to -50 degrees in 2D space */ @-webkit-keyframes counterclockwiseSpinAndFlip { /* Flip a leaf and rotate it by 50 degrees in 2D space at the start of the animation */ 0% { -webkit-transform: scale(-1, 1) rotate(50deg); } /* Flip a leaf and rotate it by -50 degrees in 2D space at the end of the animation */ 100% { -webkit-transform: scale(-1, 1) rotate(-50deg); } } |
1 2 |
<script type="text/javascript" src="/js/leaves.js"></script> <div id="leafContainer"></div> |
Спасибо! Красивый эффект.
Пожалуйста 🙂