当前位置:网站首页>【无标题】
【无标题】
2022-07-24 03:18:00 【-等天黑】
JavaScript实现下雪效果
1.效果图

2.css代码
<style type="text/css">
body {
background-color: #000000;
margin: 0;
}
img {
position: absolute;
}
</style>
3.js代码
js代码需要引入jQuery文件
<body>
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
setInterval(function() {
var img = $(`<img src="img/圣诞节-雪花.png" >`); //创建img(雪花)标签
$("body").append(img); //在body页面插入img标签
var size = Math.random() * 5 + 8; //设置img随机大小
var width = $(window).width(); //获取页面宽度
var left = Math.random() * (width - size); //图片到页面左侧随机距离
var top = $(window).height() - size; //页面高度
img.css({
"width": size + "px", //css样式
"left": left + "px"
});
img.animate({
//图片从顶部过渡到页面底部
"top": top
}, size * 150)
setTimeout(function() {
//定时器清除雪花,也可以不设置
img.remove();
}, 6000)
}, 20)
</script>
</body>
以上就是用jquery方法实现下雪效果,喜欢的话点个赞吧
边栏推荐
- Okaleido tiger NFT is about to log in to the binance NFT platform. Are you looking forward to it?
- Do the right thing, do it right
- Error code 0x80004005
- WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
- Water topic: connect rainwater
- Basic use of Pinia
- AcWing 4499. 画圆 (相似三角形)
- Rules for generating 13 digit barcode EAN-13 Code: the thirteenth digit is the verification code obtained by calculating the first twelve digits.
- Ugui source code analysis - maskutilities
- 正则表达式 \b \B 深入浅出理解单词边界的匹配
猜你喜欢

拉格朗日插值法

Outlook client outlook.com mailbox setting method

C文件操作详解

错误代码0x80004005

什么是IMU?

How does the small program mall refine the operation of members?

QT custom class uses custom parametric signals and slots

SolidWorks cannot reference references
![SSM based blog system [with background management]](/img/6b/6a488f5d6926de07c8b1b365362ff6.png)
SSM based blog system [with background management]

Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)
随机推荐
Data Lake: comparative analysis of open source data Lake schemes deltalake, Hudi and iceberg
Daily gossip (I)
uva1467
Microsoft win11/10 package manager Winget will support the installation of applications from zip files
Mobile keyboard (day 73)
Symbol type
SolidWorks CAM data cannot be recovered because a processed part has been detected.
Detailed explanation of wechat official account online customer service access methods and functions
JS array isaarray() typeof
Acwing 4499. draw a circle (similar to a triangle)
AcWing 4499. 画圆 (相似三角形)
The first edition of Niuke brush question series (automorphic number, return the number of prime numbers less than N, and the first character only appears once)
In the future, when the interviewer asks why you don't recommend using select *, please answer him loudly!
How to realize software function safety
LCD1602 - binge 51
How will you answer the "Hello world" challenge written in C language?
FTP service and configuration
How does the small program mall refine the operation of members?
Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)
B. Eastern Exhibition- Codeforces Round #703 (Div. 2)