div+css实现透视时钟指针走动显示时间代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现透视时钟指针走动显示时间代码
代码标签: div css 透视 时钟 指针 走动 显示 时间 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Rubik:wght@400;500&display=swap'> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --hue: 223; --bg: hsl(var(--hue),10%,50%); --fg: hsl(var(--hue),10%,10%); --trans-dur: 0.3s; font-size: calc(16px + (24 - 16) * (100vw - 320px) / (2560 - 320)); } body { background-color: var(--bg); color: var(--fg); display: flex; font: 1em/1.5 Rubik, sans-serif; height: 100vh; transition: background-color var(--trans-dur), color var(--trans-dur); } main { margin: auto; padding: 1.5em 0; } .clock { --hrAngle: 0; --minAngle: 0; --secAngle: 0; background-color: hsl(var(--hue),10%,90%); border-radius: 50%; box-shadow: 0.125em 0.125em 0.125em hsl(0,0%,100%) inset, -0.125em -0.125em 0.125em hsl(var(--hue),10%,70%) inset, 0.25em 0.25em 0.75em hsl(var(--hue),10%,10%,0.5); position: relative; width: 18em; height: 18em; transition: background-color var(--trans-dur), box-shadow var(--trans-dur); } .clock__words, .clock__word, .clock__word-box, .clock__hands, .clock__hand, .clock__hand-hub { position: absolute; } .clock__words { inset: 0; } .clock__word { top: calc(50% - 1.5em); left: 50%; width: 8.5em; height: 3em; perspective: 5.5em; text-transform: uppercase; transform: rotate(-90deg); transform-origin: 0 50%; } .clock__word:nth-child(1) { transform: rotate(-60deg); } .clock__word:nth-child(2) { transform: rotate(-30deg); } .clock__word:nth-child(3) { transform: rotate(0deg); } .clock__word:nth-child(4) { transform: rotate(30deg); } .clock__word:nth-child(5) { transform: rotate(60deg); } .clock__word:nth-child(6) { transform: rotate(90deg); } .clock__word:nth-child(7) { transform: rotate(120deg); } .clock__word:nth-child(8) { transform: rotate(150deg); } .clock__word:nth-child(9) { transform: rotate(180deg); } .clock__word:nth-child(10) { transform: rotate(210deg); } .clock__word:nth-child(11) { transform: rotate(240deg); } .clock__word-box { color: hsl(var(--hue),90%,40%); font-size: 3em; font-weight: 500; line-height: 1; right: 0; transform: rotateY(-45deg); transform-origin: 100% 50%; text-align: right; width: 150%; height: 100%; } .clock__word:nth-child(1) .clock__word-box { transform: rotateY(-45deg) scale(1.8,1.5); } .clock__word:nth-child(2) .clock__word-box { transform: rotateY(-45deg) scale(1.7,1.5); } .clock__word:nth-child(3) .clock__word-box { transform: rotateY(-45deg) scale(1.1,1.5); } .clock__word:nth-child(4) .clock__word-box { transform: rotateY(-45deg) scale(1.4,1.5); } .clock__word:nth-child(5) .clock__word-box { transform: rotateY(-45deg) scale(1.8,1.5); } .clock__word:nth-child(n + 6) .clock__word-box { text-align: left; } .clock__word:nth-child(6) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(2.4,1.5) translateX(100%); } .clock__word:nth-child(7) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(1.2,1.5) translateX(100%); } .clock__word:nth-child(8) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(1.3,1.5) translateX(100%); } .clock__word:nth-child(9) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(1.6,1.5) translateX(100%); } .clock__word:nth-child(10) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(2.0,1.5) translateX(100%); } .clock__word:nth-child(11) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(1.0,1.5) translateX(100%); } .clock__word:nth-child(12) .clock__word-box { transform: rotateZ(180deg) rotateY(45deg) scale(1,1.5) translateX(100%); } .clock__hands, .clock__side { top: 50%; left: 50%; } .clock__hands { filter: drop-shadow(0.25em 0.25em 0.125em hsla(0,0%,0%,0.5)) } .clock__hand, .clock__hand-hub { background-color: var(--fg); transition: background-color var(--trans-dur), box-shadow var(--trans-dur); } .clock__hand { bottom: -1.5em; left: calc(50% - 0.2em); width: 0.4em; height: 9em; transform-origin: 50% calc(100% - 1.5em); } .clock__hand-hub { border-radius: 50%; top: -0.4em; left: -0.4em; width: 0.8em; height: 0.8em; } .clock__hand--h { height: 6em; transform: rotate(var(--hrAngle)); } .clock__hand--m { transform: rotate(var(--m.........完整代码请登录后点击上方下载按钮下载查看
网友评论0