Home >Web Front-end >CSS Tutorial >css to achieve falling leaf animation effect
Purpose:
Realize the rotation and falling effect of fallen leaves.
(Learning video sharing: css video tutorial)
The code is as follows:
html code:
<div class="con"> <img src="img/yeluobig.png" id="yeluobig"/> <img src="img/yeluolit1.png" id="yeluolit1"/> <img src="img/yeluolit2.png" id="yeluolit2"/> </div>
css code:
#yeluobig{position: absolute;top: 29%;left: 30%; -webkit-animation:luo 8s infinite linear; animation:luo 8s infinite linear;} #yeluolit1{position: absolute;top: -2%;left: 40%; -webkit-animation:luo 8s infinite 2s linear; animation:luo 8s infinite 2s linear;} #yeluolit2{position: absolute;top: -2%;left: 50%; -webkit-animation:luo 8s infinite 4s linear; animation:luo 8s infinite 4s linear;} @-webkit-keyframes luo{ 0%{top: -1%;transform:rotate(-60deg);} 100%{top: 100%;transform:rotate(60deg);} } @keyframes luo{ 0%{top: -1%;transform:rotate(-60deg);} 100%{top: 100%;transform:rotate(60deg);} }
Example code and pictures:
Related recommendations: CSS tutorial
The above is the detailed content of css to achieve falling leaf animation effect. For more information, please follow other related articles on the PHP Chinese website!