纯css实现的秒表计时器代码
代码语言:html
所属分类:布局界面
代码描述:纯css实现的秒表计时器代码,无需js代码。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: grid; grid-template-rows: 1fr 1fr; gap: 4vmin; font-family: monospace; font-size: 15vmin; min-height: 100vh; color: #eee; background: hsl(200, 10%, 5%); } input { display: none; } label, button { all: unset; display: block; font-size: 0.5em; background: hsl(200, 70%, 20%); padding: 0.3em 1em; border-radius: 0.5em; box-shadow: 0.1em 0.1em #eee; text-transform: uppercase; cursor: pointer; transition: background 300ms; } :is(label, button):hover { background: hsl(200, 70%, 30%); } .clock-face { display: flex; justify-content: center; align-items: end; } .btns-container { display: flex; justify-content: center; align-items: start; gap: 0.5em; } .digit::after { content: "0"; animation: tic-10 calc(var(--duration) * 10) infinite linear paused; } .digit.six::after { animation: tic-6 calc(var(--duration) * 6) infinite linear paused; } [class*="10"]::before { content: ":"; } [for="start"]::after { content: "start"; } body:has(#start:checked) .digit::after { animation-play-state: running; } body:has(#start:checked) [for="start"]::after { content: "pause"; } body:has(.reset:active) .digit::after { animation: unset; } .hour-1 { --duration: 3600s; } .min-10 { --duration: 600s; } .min-1 { --duration: 60s; } .sec-10 { --duration: 10s; } .sec-1 { --duration: 1s; } .cent-10 { --duration: 0.1s; } .cent-1 { --duration: 0.01s; } @keyframes tic-10 { .........完整代码请登录后点击上方下载按钮下载查看
网友评论0