Home > Web Front-end > JS Tutorial > body text

jQuery implements sample code for cherry blossom falling special effects on web pages

小云云
Release: 2018-01-10 10:56:02
Original
4811 people have browsed it

This article mainly introduces jQuery to realize the special effect of cherry blossom falling on web pages. The effect is very good. Friends who need it can refer to it. I hope it can help everyone.

Reason for development

  • I saw a girl’s desktop background with a cherry blossom tree in class, and immediately came up with the idea of ​​making cherry blossoms fly on the web page. Dedicate this plug-in to that female classmate;

  • I have developed application plug-ins such as focus pictures, rotation pictures, waterfall flow, etc., but this is the first time I have made this type of plug-in, so what are you interested in? That’s right;

Development tools

  • Jquery+webstorm, no need to configure any additional environment, mobile terminal cannot be used

Effect Demonstration

In order to be more conspicuous, the background was changed to black. The gif image is a bit laggy, but the actual effect is relatively smooth.

For detailed effects, please see Github

Usage method

  • Add html code to the page where the effect needs to be added. It is best to place it in the first tag under the body element

<p class="cherry">
<img id="yinghua" src="../image/yinghua.png" alt="" >
</p>
Copy after login
  • Import the js code where each variable can be changed as needed

$(function(){
   $('.cherry').Cherry_Blossoms({
     is_Cherry:true,//是否生成樱花
     image_min:10,//花瓣最小宽度和高度
     image_max:50,//花瓣最大宽度和高度
     time_min:10000,//花瓣最快下坠时间
     time_max:20000,//花瓣最慢下坠时间
     interval:500//花瓣生成时间间隔
   })
 })
Copy after login

js plug-in

  • IIFE (immediately execute anonymous function)

  • $.extend(), extension plug-in defines default parameters

  • randomNum() sets [m,n] type random number

Related recommendations:

JavaScript to realize personalized navigation bar special effects

Using H5 to create fireworks particle special effects Method

css water wave button special effect

The above is the detailed content of jQuery implements sample code for cherry blossom falling special effects on web pages. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template