css+js实现一个三维环形上下菜单切换效果代码
代码语言:html
所属分类:菜单导航
代码描述:css+js实现一个三维环形上下菜单切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; display: grid; place-items: center; overflow: hidden; font-family: sans-serif; background-color: rgb(6, 6, 6); background-image: linear-gradient(rgb(0, 0, 0, 0.5), rgb(0, 0, 0, 0.5)); color: white; transition: background-color 500ms ease; } /* header */ header { position: absolute; z-index: 999; text-align: center; top: 0rem; padding: 1rem; background: inherit; } .container { position: relative; width: min(400px, 100%); } /* holidays */ ul { list-style: none; width: 100%; height: 100%; position: relative; perspective: 900px; transform-style: preserve-3d; } ul > li { position: absolute; left: 50%; top: calc(50% - 1.2rem); --rotateX: calc( 1deg * var(--rotateDegrees) * calc(var(--day_idx) - var(--currentDay)) ); transform: rotateX(var(--rotateX)) translateZ(190px) translateX(-50%) scale(var(--scale, 1)); --hue: calc(var(--rotateDegrees) * var(--day_idx)); background-color: hsl(var(--hue), 50%, var(--lightness, 50%)); width: 70%; color: white; display: grid; grid-template-columns: 2.5rem auto; height: 2.4rem; transition: transform 500ms ease, background-color 500ms ease; } ul > li.active { --lightness: 30%; --scale: 1.1; } ul > li > * { display: grid; align-items: center; } li > time { text-align: center; } li > span { padding-inline-start: 0.5rem; color: white; } /* controls */ .controls { position: absolute; top: 50%; left: 100%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 0.125rem; } .controls button { width: 1.5rem; aspect-ratio: 1; font-size: 0.9rem; color: white; border: none; background: #39657e; display: grid; place-items: center; } .controls button:hover, .controls button:focus { background: rgb(6, 60, 131); } .controls button:active { transform: scale(0.9); } .border { width: 96%; height: 3em; border: 1px solid white; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } </style> </head> <body> <div class="container"> <ul>.........完整代码请登录后点击上方下载按钮下载查看
网友评论0