Home >Web Front-end >CSS Tutorial >How to achieve the effect of falling snowflakes with CSS3
Use the animation property in CSS3 to set the animation name, animation time, speed and whether the animation loops to achieve the effect of falling snowflakes
What I will share today is to use the animation attribute in CSS3 to achieve the effect of falling snowflakes. It has a certain reference effect and I hope it will be helpful to everyone.
【Recommended Course: CSS3 Tutorial】
##Production Background picture
We can use the drawing software on the computer to draw the pattern you want to draw, such as small stars, snowflakes, hearts, etc. In this example, draw a black background on the canvas and then draw snowflakesProgram ideas:
First add the body A color that is the same as the background color of the picture, and then use position: fixed to generate an absolutely positioned element, position it relative to the browser window, and then set its upper, lower, left and right values to 0, in order to make the pictures fit closely together. Finally, use the animation attribute to set the animation effect We can set the animation according to the animation effect we want, such as in this example:animation: xuehua 15s linear infinite;
Program code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title></title> <style> body{ background: #000; } #xuehua{ position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: url('images/xuehua.png'); -webkit-animation: xuehua15s linear infinite; animation: snow 15s linear infinite; } @keyframes xuehua{ 0% { background-position: 0 0, 0 0; } 100% { background-position: 500px 1000px, 500px 500px; } } @-webkit-keyframes xuehua{ 0% { background-position: 0 0, 0 0; } 100% { background-position: 500px 1000px, 500px 500px; } } </style> </head> <body> <div id="xuehua"></div> </body> </html>The renderings are as follows: Summary: The above is the entire content of this article. I hope that through this article you can learn to create special effects of falling snowflakes.
The above is the detailed content of How to achieve the effect of falling snowflakes with CSS3. For more information, please follow other related articles on the PHP Chinese website!