分享一个新年跨年倒计时html静态源码,源码里只有图片、CSS、JS、HTML文件,文件大小共计300KB左右。
源码效果:访问后,鼠标点击显示一个新年跨年倒计时。并且,每次点击鼠标,都会放一个烟花,效果还是不错的。
源码下载
链接:https://pan.xunlei.com/s/VNKmBWuBvo13iQ-X3lEcNcZpA1?pwd=47yq#
复制这段内容后打开手机迅雷App,查看更方便
附上上述链接打开迅雷即可下载,或者电脑端直接访问链接。
源码使用
源码解压后,放于网站目录,访问网站目录即可看到实际效果
源码演示效果
访问网站即可查看源码实际效果:https://demo.iymark.com/new-year/
源码修改
源码是基于元旦的时间设置的倒计时,如果你想改成春节倒计时,只需要修改index.html中的部分代码,修改方法如下:
window.setTimeout("time()", 1000);
var seconds = 1000
var minutes = seconds * 60
var hours = minutes * 60
var days = hours * 24
var years = days * 365
var today = new Date()
var todayYear = today.getFullYear()
var newYear=todayYear+1
var lastYear=todayYear-1
var todayMonth = today.getMonth() + 1
var todayDate = today.getDate()
var todayHour = today.getHours()
var todayMinute = today.getMinutes()
var todaySecond = today.getSeconds()
var t1 = Date.UTC(newYear, 1, 22, 0, 00, 00)
var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond)
var diff = t1 - t2
var diff2 = t2-t1
var diffYears = Math.floor(diff / years)
var diffDays = Math.floor((diff / days) - diffYears * 365)
var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours)
var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes)
var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours - diffMinutes *
minutes) / seconds)
var diff2Years = Math.floor(diff2 / years)
var diff2Days = Math.floor((diff2 / days) - diff2Years * 365)
var diff2Hours = Math.floor((diff2 - (diff2Years * 365 + diff2Days) * days) / hours)
var diff2Minutes = Math.floor((diff2 - (diff2Years * 365 + diff2Days) * days - diff2Hours * hours) / minutes)
var diff2Seconds = Math.floor((diff2 - (diff2Years * 365 + diff2Days) * days - diff2Hours * hours - diff2Minutes *
minutes) / seconds)
if(todayMonth==1){if(todayDate==22){document.getElementById("text1").innerHTML = "现在是1月22日,正月初一,祝你"+todayYear+"新春快乐!"}}
else{document.getElementById("text1").innerHTML = "提前祝你"+newYear+"新年快乐"}
document.getElementById("time").innerHTML = diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒"+ "到达正月初一,提前祝你新春快乐!"
修改代码中的t1时间为1月22日即为2023年的正月初一,上述代码中的结尾部分的时间及描述也可以修改。你可以自行通过上述源码与网盘里的源码不同的地方进行修改。当然,文中的演示网址目前已改为春节快乐。
原创文章,作者:古哥,转载需经过作者授权同意,并附上原文链接:https://iymark.com/articles/3943.html