纯css实现秒表计时器按下结束效果代码
代码语言:html
所属分类:布局界面
代码描述:纯css实现秒表计时器按下结束效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap"); *, *:after, *:before { box-sizing: border-box; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } :root { --state: paused; --bg: #ead9f2; --digit: #e6f2d9; --face: #0d1306; --content: #666; --shadow: rgba(0,0,0,0.25); --glare: rgba(255,255,255,0.2); --watch-bg: #197fe6; --watch-bg--light: #d1e5fa; --watch-bg--dark: #0a335c; --stroke: #262626; --start: #b83014; --start-two: #eb6347; --restart: #b3b3b3; --restart-two: #e6e6e6; } #start:checked ~ .stopwatch__content .ms--tens, #pause:checked ~ .stopwatch__content .ms--tens { --name: ms-tens; } #start:checked ~ .stopwatch__content .ms--singles, #pause:checked ~ .stopwatch__content .ms--singles { --name: ms-singles; } #start:checked ~ .stopwatch__content .s--tens, #pause:checked ~ .stopwatch__content .s--tens { --name: s-tens; } #start:checked ~ .stopwatch__content .s--singles, #pause:checked ~ .stopwatch__content .s--singles { --name: s-singles; } #start:checked ~ .stopwatch__content .m--tens, #pause:checked ~ .stopwatch__content .m--tens { --name: m-tens; } #start:checked ~ .stopwatch__content .m--singles, #pause:checked ~ .stopwatch__content .m--singles { --name: m-singles; } #start:checked ~ .stopwatch__content { --state: running; } #pause:checked ~ .stopwatch__content { --state: paused; } #start:checked ~ .stopwatch__start { z-index: -1; } .stopwatch__start:active ~ .stopwatch__stop-start, .stopwatch__pause:active ~ .stopwatch__stop-start { --y: 25; } .stopwatch__reset:active ~ .stopwatch__restart { --y: 15; } @property --ms-tens { initial-value: 0; inherits: false; syntax: '<integer>'; } @property --ms-singles { initial-value: 0; inherits: false; syntax: '<integer>'; } @property --s-tens { initial-value: 0; inherits: false; syntax: '<integer>'; } @property --s-singles { initial-value: 0; inherits: false; syntax: '<integer>'; } @property --m-tens { initial-value: 0; inherits: false; syntax: '<integer>'; } @property --m-singles { initial-value: 0; inherits: false; syntax: '<integer>'; } body { min-height: 100vh; display: grid; font-family: 'Orbitron', sans-serif; background: var(--bg); place-items: center; } form { margin: 0; } button { -webkit-appearance: none; -moz-appearance: none; appearance: none; border: 0; outline: transparent; background: none; } label span, button span, [type="checkbox"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; } label, button { cursor: pointer; } .reset-button { width: 100%; height: 50%; position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); border: 0.5vmin solid var(--stroke); border-radius: 1vmin; background: var(--restart); overflow: hidden; } .reset-button:after { height: 100%; width: 100%; position: absolute; top: 0; left: 0; background: repeating-linear-gradient(90deg, transparent 0 18%, var(--stroke) 18% 22%) 50% 0/100% 30% no-repeat, repeating-linear-gradient(90deg, transparent 0 18%, var(--stroke) 18% 22%) 50% 100%/100% 30% no-repeat; content: ''; } .reset-button:before { content: ''; height: 100%; width: 100%; border-radius: 1vmin; background: var(--restart-two); position: absolute; bottom: 100%; left: 0; transform: translate(-20%, 45%); } .start-button { width: 100%; height: 60%; position: absolute; bottom: 0; border: 0.5vmin solid var(--stroke); border-radius: 1vmin; background: var(--start); overflow: hidden; } .start-button:after { content: ''; height: 100%; width: 100%; border-radius: 1vmin; background: var(--start-two); position: absolute; bottom: 100%; left: 0; transform: translate(-20%, 35%); } .stopwatch { height: 45vmin; width: 45vmin; background-color: var(--watch-bg); border-radius: 50%; border: 0.5vmin solid var(--stroke); position: relative; } .stopwatch__pause, .stopwatch__start, .stopwatch__reset, .stopwatch__control { --size: 10vmin; height: var(--size); width: var(--size); position: absolute; top: 50%; left: 50%; transition: transform 0.05s; transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) translate(0, -25vmin) translateY(calc(var(--y, 0) * 1%)); z-index: 10; } .stopwatch__control { z-index: -1; } .stopwatch__restart:before { content: ''; position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 0); width: 60%; height: 75%; border: 0.5vmin solid var(--stroke); background: linear-gradient(90deg, var(--restart-two) 0 80%, transparent 81%) 50% 50%/100% 100% no-repeat; background-color: var(--restart); z-index: -1; } .stopwatch__start, .stopwatch__pause, .stopwatch__stop-start { --rotation: 40deg; } .stopwatch__shadows { height: 100%; width: 100%; border-radius: 100%; position: absol.........完整代码请登录后点击上方下载按钮下载查看
网友评论0