原生js实现圈圈圆环进度节日倒计时代码
代码语言:html
所属分类:其他
代码描述:原生js实现圈圈圆环进度节日倒计时代码
代码标签: 原生 js 圈圈 圆环 进度 节日 倒计时 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @layer demo, countdown; @layer countdown{ .countdown { width: fit-content; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1rem; } .countdown > .part { display: grid; gap: 0.5rem; } .countdown > .part > .number { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; border: 1px solid hsl(0 0% 50% / .5); font-size: 1.5rem; position: relative } .countdown > .part.days { --num: 365 } .countdown > .part.hours { --num: 24 } .countdown > .part:where(.minutes, .seconds) { --num: 60 } .countdown > .part > .number::after{ content: ""; position: absolute; inset: calc(var(--border-size) * -0.5); border-radius: inherit; --degree: calc(360deg / var(--num) * (var(--num) - var(--value,0))); background-image: conic-gradient(var(--accent) var(--degree), transparent calc(var(--degree) + 0.1deg)); --border-size: 4px; --mask-image: radial-gradient(100% 100%, transparent calc(50% - var(--border-size)), black calc(50% - var(--border-size) + 1px)); -webkit-mask-image: var(--mask-image); mask-image: var(--mask-image); } .countdown > .part > .text { text-align: center; opacity: 0.75 } } @layer demo { * { box-sizing: border-box } body { background-color: #060D1F; color: #FEFEFE; font-family: system-ui, sans-serif; text-align: center; } h2 { margin-top: 4rem; } } </style> </head> <body > <h2>Christmas '22</h2> <time class="countdown" date-time="2022-12-25 00:00:00" style="--accent: red"></time> <h2>New Year '23</h2> <time class="countdown" date-time="2023-01-01 00:00:00" style="--accent: green"></time> <h2>Custom</h2> &.........完整代码请登录后点击上方下载按钮下载查看
网友评论0