Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
New Year Countdown
00
Days
00
Hours
00
Minutes
00
Seconds
css
@import url("https://fonts.googleapis.com/css?family=Aleo"); :root { font-family: "Aleo", sans-serif; } html, body { width: 100%; height: 100%; padding: 0; margin: 0; background: rgb(119, 13, 13); background: radial-gradient( circle, rgba(119, 13, 13, 0.92) 64%, rgba(0, 0, 0, 0.6) 100% ); } canvas { width: 100%; height: 100%; } .label { font-size: 2.2rem; background: url("https://www.jq22.com/tp/6377582078649082695643686.png"); background-clip: text; -webkit-background-clip: text; color: transparent; animation: moveBg 30s linear infinite; } @keyframes moveBg { 0% { background-position: 0% 30%; } 100% { background-position: 1000% 500%; } } .middle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; user-select: none; } .time { color: #d99c3b; text-transform: uppercase; display: flex; justify-content: center; } .time span { padding: 0 14px; font-size: 0.8rem; } .time span div { font-size: 3rem; } @media (max-width: 740px) { .label { font-size: 1.7rem; } .time span { padding: 0 16px; font-size: 0.6rem; } .time span div { font-size: 2rem; } }
JavaScript
class Snowflake { constructor() { this.x = 0; this.y = 0; this.vx = 0; this.vy = 0; this.radius = 0; this.alpha = 0; this.reset(); } reset() { this.x = this.randBetween(0, window.innerWidth); this.y = this.randBetween(0, -window.innerHeight); this.vx = this.randBetween(-3, 3); this.vy = this.randBetween(2, 5); this.radius = this.randBetween(1, 4); this.alpha = this.randBetween(0.1, 0.9); } randBetween(min, max) { return min + Math.random() * (max - min); } update() { this.x += this.vx; this.y += this.vy; if (this.y + this.radius > window.innerHeight) { this.reset(); } } } class Snow { constructor() { this.canvas = document.createElement("canvas"); this.ctx = this.canvas.getContext("2d"); document.body.appendChild(this.canvas); window.addEventListener("resize", () => this.onResize()); this.onResize(); this.updateBound = this.update.bind(this); requestAnimationFrame(this.updateBound); this.createSnowflakes(); } onResize() { this.width = window.innerWidth; this.height = window.innerHeight; this.canvas.width = this.width; this.canvas.height = this.height; } createSnowflakes() { const flakes = window.innerWidth / 4; this.snowflakes = []; for (let s = 0; s < flakes; s++) { this.snowflakes.push(new Snowflake()); } } update() { this.ctx.clearRect(0, 0, this.width, this.height); for (let flake of this.snowflakes) { flake.update(); this.ctx.save(); this.ctx.fillStyle = "#FFF"; this.ctx.beginPath(); this.ctx.arc(flake.x, flake.y, flake.radius, 0, Math.PI * 2); this.ctx.closePath(); this.ctx.globalAlpha = flake.alpha; this.ctx.fill(); this.ctx.restore(); } requestAnimationFrame(this.updateBound); } } new Snow(); //////////////////////////////////////////////////////////// // Simple CountDown Clock const d = document.getElementById("d"); const h = document.getElementById("h"); const m = document.getElementById("m"); const s = document.getElementById("s"); function getTrueNumber(num) { return num < 10 ? "0" + num : num; } function calculateRemainingTime() { const comingYear = new Date().getFullYear() + 1; const comingDate = new Date(`Jan 1, ${comingYear} 00:00:00`); const now = new Date(); const remainingTime = comingDate.getTime() - now.getTime(); const days = Math.floor(remainingTime / (1000 * 60 * 60 * 24)); const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const mins = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60)); const secs = Math.floor((remainingTime % (1000 * 60)) / 1000); d.innerHTML = getTrueNumber(days); h.innerHTML = getTrueNumber(hours); m.innerHTML = getTrueNumber(mins); s.innerHTML = getTrueNumber(secs); return remainingTime; } function initCountdown() { const interval = setInterval(() => { const remainingTimeInMs = calculateRemainingTime(); if (remainingTimeInMs <= 1000) { clearInterval(interval); initCountdown(); } }, 1000); } initCountdown();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>新年倒计时-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号