js+css实现木质立体质感墙上时钟显示时间代码
代码语言:html
所属分类:布局界面
代码描述:js+css实现木质立体质感墙上时钟显示时间代码
代码标签: js 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=Lobster+Two&display=swap'> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --hue: 223; --goldHue: 45; --goldSat: 40%; --bg: hsl(var(--hue),10%,90%); --fg: hsl(var(--hue),10%,10%); --primary: hsl(var(--hue),90%,50%); --trans-dur: 0.3s; font-size: calc(16px + (32 - 16) * (100vw - 320px) / (2560 - 320)); } body { background-color: var(--bg); color: var(--fg); display: flex; font: 1em/1.5 "Lobster Two", serif; height: 100vh; transition: background-color var(--trans-dur), color var(--trans-dur); } .clock { margin: auto; position: relative; width: 16em; height: 16em; } .clock__frames, .clock__frame, .clock__frame-cracks, .clock__frame-crack, .clock__hands, .clock__hand, .clock__hour, .clock__hub, .clock__inside, .clock__inside:before, .clock__inside:after, .clock__tick { position: absolute; } .clock__frames, .clock__hands { filter: drop-shadow(0 0.25em 0.125em rgba(0, 0, 0, 0.7)); } .clock__frames, .clock__frame-cracks { top: 0; left: 0; width: 100%; height: 100%; } .clock__frame { background: url("//repo.bfw.wiki/bfwrepo/image/634361f30f92e.png") 0 0/100% 100%, #814d22; bottom: 50%; clip-path: polygon(0 0, 100% 0, 94% 100%, 6% 100%); left: calc(50% - 3.35em); width: 6.7em; height: 1em; transform-origin: 50% 100%; } .clock__frame:nth-child(1) { transform: rotate(45deg) translateY(-7em); } .clock__frame:nth-child(2) { transform: rotate(90deg) translateY(-7em); } .clock__frame:nth-child(3) { transform: rotate(135deg) translateY(-7em); } .clock__frame:nth-child(4) { transform: rotate(180deg) translateY(-7em); } .clock__frame:nth-child(5) { transform: rotate(225deg) translateY(-7em); } .clock__frame:nth-child(6) { transform: rotate(270deg) translateY(-7em); } .clock__frame:nth-child(7) { transform: rotate(315deg) translateY(-7em); } .clock__frame:nth-child(8) { transform: rotate(360deg) translateY(-7em); } .clock__frame-crack { background-color: rgba(0, 0, 0, 0.7); border-radius: 0.05em; bottom: 50%; left: calc(50% - 0.05em); width: 0.1em; height: 1em; transform-origin: 50% 100%; } .clock__frame-crack:nth-child(1) { transform: rotate(67.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(2) { transform: rotate(112.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(3) { transform: rotate(157.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(4) { transform: rotate(202.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(5) { transform: rotate(247.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(6) { transform: rotate(292.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(7) { transform: rotate(337.5deg) translateY(-7.6em); } .clock__frame-crack:nth-child(8) { transform: rotate(382.5deg) translateY(-7.6em); } .clock__hands, .clock__hour, .clock__tick { z-index: 1; } .clock__hands { top: 50%; left: 50%; } .clock__hand, .clock__hub { background-color: var(--fg); } .clock__hand { bottom: calc(50% - 1em); clip-path: polygon(50% 0, 100% 0.87em, 75% 100%, 25% 100%, 0 0.87em); left: calc(50% - 0.375em); transform-origin: 50% calc(100% - 1em); width: 0.75em; } .clock__hand--hr { height: 4em; } .clock__hand--min { height: 6.5em; } .clock__hour { font-size: 2em; line-height: 1; text-align: center; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.5); bottom: calc(50% - 1rem); left: calc(50% - 1rem); width: 2rem; height: 2rem; } .clock__hour--1 { transform: rotate(30deg) translateY(-4.625rem) rotate(-30deg); } .clock__hour--2 { transform: rotate(60deg) translateY(-4.625rem) rotate(-60deg); } .clock__hour--3 { transform: rotate(90deg) translateY(-4.625rem) rotate(-90deg); } .clock__hour--4 { transform: rotate(120deg) translateY(-4.625rem) rotate(-120deg); } .clock__hour--5 { transform: rotate(150deg) translateY(-4.625rem) rotate(-150deg); } .clock__hour--6 { transform: rotate(180deg) translateY(-4.625rem) rotate(-180deg); } .clock__hour--7 { transform: rotate(210deg) translateY(-4.625rem) rotate(-210deg); } .clock__hour--8 { transform: rotate(240deg) translateY(-4.625rem) rotate(-240deg); } .clock__hour--9 { transform: rotate(270deg) translateY(-4.625rem) rotate(-270deg); } .clock__hour--10 { transform: rotate(300deg) translateY(-4.625rem) rotate(-300deg); } .clock__hour--11 { transform: rotate(330deg) translateY(-4.625rem) rotate(-330deg); } .clock__hour--12 { transform: rotate(360deg) translateY(-4.625rem) rotate(-360deg); } .clock__hub { border-radius: 50%; box-shadow: 0.05em 0.05em 0 rgba(255, 255, 255, 0.1) inset, -0.05em -0.05em 0 rgba(0, 0, 0, 0.4) inset; bottom: calc(50% - 0.55em); left: calc(50% - 0.55em); width: 1.1em; height: 1.1em; z-index: 2; } .clock__inside { background-image: linear-gradient(10deg, hsl(var(--goldHue), var(--goldSat), 94%) 10%, hsl(var(--goldHue), var(--goldSat), 54%) 16%, hsl(var(--goldHue), var(--goldSat), 24%)); clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0% 71%, 0% 29%); width: 100%; height: 100%; } .clock__inside:before, .clock__inside:after { border-radius: 50%; content: ""; display: block; } .clock__inside:before { background-image: radial-gradient(100% 100% at center, hsla(var(--hue), 10%, 10%, 0) 5.99em, hsl(var(--hue), 10%, 10%) 6em 6.04em, hsla(var(--hue), 10%, 10%, 0) 6.05em), radial-gradient(100% 100% at center, hsla(var(--hue), 10%, 10%, 0) 5.74em, hsl(var(--hue), 10%, 10%) 5.75em 5.79em, hsla(var(--hue), 10%, 10%, 0) 5.8em), radial-gradient(100% 100% at 65% 25%, hsl(var(--goldHue), var(--goldSat), 94%) 5%, rgba(248, 242, 231, 0) 20%), radial-gradient(100% 200% at 55% 95%, hsla(var(--goldHue), var(--goldSat), 4%, 0.2) 10%, hsla(var(--goldHue), var(--goldSat), 4%, 0) 15%), radial-gradient(100% 100% at center, hsla(var(--goldHue), var(--goldSat), 4%, 0.2) 20%, hsla(var(--goldHue), var(--goldSat), 4%, 0) 30%), radial-gradient(100% 100% at 20% 85%, hsl(var(--goldHue), var(--goldSat), 94%) 5%, hsl(var(--goldHue), var(--goldSat), 39%) 25%); box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.4), 0 0 1em 1em rgba(0, 0, 0, 0.15) inset; top: calc(50% - 6.375em); left: calc(50% - 6.375em); width: 12.75em; height: 12.75em; } .clock__inside:after { background-image: linear-gradient(0deg, hsl(var(--goldHue), var(--goldSat), 54%), hsl(var(--goldHue), var(--goldSat), 34%)); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset; top: calc(50% - 3.25em); left: calc(50% - 3.25em); width: 6.5em; height: 6.5em; } .clock__tick { background-color: var(--fg); bottom: 50%; left: calc(50% - 0.035em); width: 0.07em; height: 0.25em; transform-origin: 50% 100%; } .clock__tick:nth-child(5n) { clip-path: polygon(0 0, 100% 0, 50% 100%); left: calc(50% - 0.15em); width: 0.3em; } .clock__tick:nth-child(1) { transform: rotate(6deg) translateY(-5.75em); } .clock__tick:nth-child(2) { transform: rotate(12deg) translateY(-5.75em); } .clock__tick:nth-child(3) { transform: rotate(18deg) translateY(-5.75em); } .clock__tick:nth-child(4) { transform: rotate(24deg) translateY(-5.75em); } .clock__tick:nth-child(5) { transform: rotate(30deg) translateY(-5.75em); } .clock__tick:nth-child(6) { transform: rotate(36deg) translateY(-5.75em); } .clock__tick:nth-child(7) { transform: rotate(42deg) translateY(-5.75em); } .clock__tick:nth-child(8) { transform: rotate(48deg) translateY(-5.75em); } .clock__tick:nth-child(9) { transform: rotate(54deg) translateY(-5.75em); } .clock__tick:nth-child(10) { transform: rotate(60deg) translateY(-5.75em); } .clock__tick:nth-child(11) { transform: rotate(66deg) translateY(-5.75em); } .clock__tick:nth-child(12) { transform: rotate(72deg) translateY(-5.75em); } .clock__tick:nth-child(13) { transform: rotate(78deg) translateY(-5.75em); } .clock__tick:nth-child(14) { transform: rotate(84deg) translateY(-5.75em); } .clock__tick:nth-child(15) { transform: rotate(90deg) translateY(-5.75em); } .clock__tick:nth-child(16) { transform: rotate(96deg) translateY(-5.75em); } .clock__tick:nth-child(17) { transform: rotate(102deg) translateY(-5.75em); } .clock__tick:nth-child(18) { transform: rotate(108deg) translateY(-5.75em); } .clock__tick:nth-child(19) { transform: rotate(114deg) translateY(-5.75em); } .clock__tick:nth-child(20) { transform: rotate(120deg) translateY(-5.75em); } .clock__tick:nth-child(21) { transform: rotate(126deg) translateY(-5.75em); } .clock__tick:nth-child(22) { transform: rotate(132deg) translateY(-5.75em); } .clock__tick:nth-child(23) { transform: rotate(138deg) translateY(-5.75em); } .clock__tick:nth-child(24) { transform: rotate(144deg) translateY(-5.75em); } .clock__tick:nth-child(25) { transform: rotate(150deg) translateY(-5.75em); } .clock__tick:nth-child(26) { transform: rotate(156deg) translateY(-5.75em); } .clock__tick:nth-child(27) { transform: rotate(162deg) translateY(-5.75em); } .clock__tick:nth-child(28) { transform: rotate(168deg) translateY(-5.75em); } .clock__tick:nth-child(29) { transform: rotate(174deg) translateY(-5.75em); } .clock__tick:nth-child(30) { transform: rotate(180deg) translateY(-5.75em); } .clock__tick:nth-child(31) { transform: rotate(186deg) translateY(-5.75em); } .clock__tick:nth-child(32) { transform: rotate(192deg) translateY(-5.75em); } .clock__tick:n.........完整代码请登录后点击上方下载按钮下载查看
网友评论0