大冬天的,飄雪花的特效,你可能要用上了吧。通常情況下用jQuery寫飄雪花的特效,但用css3寫,其實特別簡單,新手一看就懂,那就告別jQuery,用css3輕松搞定飄雪花特效吧!
代碼如下:
<!DOCTYPE html> <html> <head> <meta charset="gb2312"> <title>css3飄雪花特效</title> <style type="text/css"> body { margin: 0; padding: 0; background:#000; } img { display: block; width: 100%; } @keyframes snow{ 0% { background-position: 0 0, 0 0; } 100% { background-position: 500px 500px, 1000px 500px; } } .snow{ position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: url('snow1.png'),url('snow2.png'); animation: 10s snow linear infinite; } </style> </head> <body> <div class="snow"></div> </body> </html>
總結:這個css3飄雪花特效,對於新手很簡單。主要用到了css3多背景、css3動畫知識點,如果對這些知識點不熟悉,建議趕快再復習下,補補課。