js+css实现立体倒影投影数字时钟走动显示当前时间效果代码
代码语言:html
所属分类:其他
代码描述:js+css实现立体倒影投影数字时钟走动显示当前时间效果代码
代码标签: js css 立体 倒影 投影 数字 时钟 走动 显示 当前 时间
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500&display=swap'); *, *::before, *::after { font-family: inherit; box-sizing: inherit; margin: 0; padding: 0; } html { font-size: 0.75vmin; font-family: 'Poppins', sans-serif; margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; } body { background-image: linear-gradient(to bottom, #2C2A38, #2c303b); perspective: 45rem; transform-style: preserve-3d; font-family: 'Poppins', sans-serif; } .wrapper { animation: camera-rotate 40s ease-in-out forwards infinite; width: 100%; height: 100%; transform-style: preserve-3d; } main { --s: 100%; --l: 50%; display: flex; color: rgba(255, 255, 255, 0.3); gap: 1rem; width: 100%; height: 100%; position: relative; align-items: center; justify-content: center; animation-composition: add; /* for hue rotate(laggy thou) */ animation: camera-pan 30s linear forwards infinite; translate: 0rem 1rem 10rem; transform-style: preserve-3d; } main .digits { transform-style: preserve-3d; } main .digits .group { display: flex; gap: 2rem; } main .digits .group .digit { position: relative; height: 16rem; aspect-ratio: 1/2; filter: drop-shadow(0px 0px 4px currentColor) drop-shadow(0px 0px 10px currentColor); } main .digits .group .digit span { --act: 0; --signX: 1; --signY: 1; position: absolute; background-color: white; transition: all 0.3s cubic-bezier(0.17, 0.67, 0.5, 1.15); opacity: calc(0.03 + 0.97 * var(--act)); animation-composition: add; transform: scale(var(--signX), var(--signY)); } main .digits .group .digit span.end { clip-path: polygon(15% 0%, 7.5% 20%, 25% 100%, 75% 100%, 92.5% 20%, 85% 0%); width: 100%; height: 10%; } main .digits .group .digit span.end.top { top: 0; } main .digits .group .digit span.end.bottom { top: initial; bottom: 0; --signY: -1; } main .digits .group .digit span.side { clip-path: polygon(0% 15%, 20% 7.5%, 100% 22.5%, 100% 85%, 20% 95%, 0% 90%); height: 50%; width: 20%; } main .digits .group .digit span.side.left { top: 0; left: 0; } main .digits .group .digit span.side.left.bottom { top: initial; bottom: 0; --signY: -1; } main .digits .group .digit span.side.right { top: 0; left: initial; right: 0; --signX: -1; } main .digits .group .digit span.side.right.bottom { top: initial; --signY: -1; bottom: 0; } main .digits .group .digit span.middle { clip-path: polygon(22.5% 0%, 6.5% 50%, 22.5% 100%, 77.5% 100%, 93.5% 50%, 77.5% 0%); top: 45%; height: 10%; width: 100%; } main .digits .group .digit[data-digit="0"] :not(.middle) { --act: 1; } main .digits .group .digit[data-digit="1"] .right { --act: 1; } main .digits .group .digit[data-digit="2"] :not(.top.left, .bottom.right) { --act: 1; } main .digits .group .digit[data-digit="3"] :not(.left) { --act: 1; } main .digits .group .digit[data-digit="4"] :not(.end, .bottom.left) { --act: 1; } main .digits .group .digit[data-digit="5"] :not(.top.right, .bottom.left) { --act: 1; } main .digits .group .digit[data-digit="6"] :not(.top.right) { --act: 1; } main .digits .group .digit[data-digit="7"] .top, main .digits .group .digit[data-digit="7"] .right { --act: 1; } main .digits .group .digit[data-digit="8"] > * { --act: 1; } main .digits .group .digit[data-digit="9"] :not(.bottom.left) { --act: 1; } main .colon-group { transform-style: preserve-3d; } main .colon-group .colon span { display: flex; height: 16rem; flex-direction: column; justify-content: space-evenly; width: 4rem; align-items: center; filter: drop-shadow(0px 0px 4px currentColor) drop-shadow(0px 0px 10px currentColor); } main .colon-group .colon span::before, main .colon-group .colon span::after { content: ""; display: block; width: 2rem; aspect-ratio: 1/1; background-color: white; border-radius: 2rem; } main .shadow { top: 0; position: absolute; transform-origin: bottom center; transform: translateY(1rem) translateZ(2rem) rotateX(-90.1deg); } main .shadow .digit span { opacity: var(--act); } main .shadow.shadow1 { opacity: 0.5; filter: drop-shadow(0px 0px 4px currentColor) drop-shadow(0px 0px 10px currentColor) blur(4rem); } main .shadow.shadow1 > span, main .shadow.shadow1 .digit { mask-image: linear-gradient(to bottom, white, rgba(0, 0, 0, 0.5)); } main .shadow.shadow2 { opacity: 0.4; filter: drop-shadow(0px 0px 4px currentColor) drop-shadow(0px 0px 10px currentColor) blur(4px); } main .shadow.shadow2 > span, main .shadow.shadow2 .digit { opacity: var(--act); mask-image: linear-gradient(to top, black, rgba(0, 0, 0, 0.1) 60%, rgba(0, 0, 0, 0)); } @keyframes camera-rotate { 0% { transform: rotateY(-10deg); } 50% { transform: rotateY(10deg); } 100% { transform: rotateY(-10deg); } } @keyframes camera-pan { 0% { transform: translate(0rem, 0rem); } 20% { transform: translate(1rem, 2rem); } 40% { transform: translate(-2rem, 2.5rem); .........完整代码请登录后点击上方下载按钮下载查看
网友评论0