js+css实现霓虹灯投影三维数字时钟时间走动效果代码
代码语言:html
所属分类:布局界面
代码描述:js+css实现霓虹灯投影三维数字时钟时间走动效果代码
代码标签: js css 霓虹灯 投影 三维 数字 时钟 时间 走动
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, *::before, *::after { font-family: inherit; box-sizing: inherit; margin: 0; padding: 0; } html { box-sizing: border-box; font-family: 'Nunito Sans', sans-serif; font-size: 62.5%; } html body { font-size: 1.6rem; margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; } ul { list-style: none; } a, a:link, a:visited { text-decoration: none; } .safari { .digit span { // 3d transform with filter animation is broken on Safari transition: none !important; &::before { content: ''; position: absolute; display: block; // prevent the bounding box to be cut off during animation width: 400%; height: 400%; top: 0; left: 0; transform: translate(-50%, -50%); } } } </style> <style> html { font-size: 0.75vmin; } body { background-image: linear-gradient(to bottom, #131313, #000); perspective: 45rem; transform-style: preserve-3d; } main { --color: #1fa3ef; display: flex; gap: 1rem; width: 100%; height: 100%; position: relative; align-items: center; justify-content: center; animation-composition: add; -webkit-animation: camera-rotate 40s ease-in-out forwards infinite, camera-pan 30s linear forwards infinite; animation: camera-rotate 40s ease-in-out forwards infinite, camera-pan 30s linear forwards infinite; transform: rotateY(var(--angle)); 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 var(--color)) drop-shadow(0px 0px 10px var(--color)); } 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; scale: var(--signX) var(--signY); } main .digits .group .digit span.end { -webkit-clip-path: polygon(15% 0%, 7.5% 20%, 25% 100%, 75% 100%, 92.5% 20%, 85% 0%); 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 { -webkit-clip-path: polygon(0% 15%, 20% 7.5%, 100% 22.5%, 100% 85%, 20% 95%, 0% 90%); 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 { -webkit-clip-path: polygon(22.5% 0%, 6.5% 50%, 22.5% 100%, 77.5% 100%, 93.5% 50%, 77.5% 0%); 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 var(--color)) drop-shadow(0px 0px 10px var(--color)); } 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 var(--color)) drop-shadow(0px 0px 10px var(--color)) blur(4rem); } main .shadow.shadow1 > span, main .shadow.shadow1 .digit { -webkit-mask-image: linear-gradient(to bottom, white, rgba(0, 0, 0, 0.5)); 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 var(--color)) drop-shadow(0px 0px 10px var(--color)) blur(4px); } main .shadow.shadow2 > span, main.........完整代码请登录后点击上方下载按钮下载查看
网友评论0