div+css实现立体进度条抖动加载动画效果代码
代码语言:html
所属分类:加载滚动
代码描述:div+css实现立体进度条抖动加载动画效果代码,鼠标悬浮可切换视角,鼠标按住不放可暂停。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Days+One&family=Gluten&display=swap'); :root { --bg: #3d373f; --sp: 0.45s; --dy: calc(var(--sp) / 8); --ttf: cubic-bezier(0.25, 0.46, 0.45, 0.94); } * { transform-style: preserve-3d; box-sizing: border-box; } body { margin: 0; padding: 0; width: 100vw; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--bg); flex-wrap: wrap; } body:before, body:after { content: "hover to change perspective"; position: absolute; width: 100%; text-align: center; text-transform: uppercase; font-family: 'Gluten', Arial, Helvetica, serif; color: #796b79; text-shadow: 0px -1px 1px #c9b0c9cc, 0px -1px 0 #0008, 0px 2px 2px #0008; top: 5vh; left: 0; z-index: -1; } body:after { content: "click & hold to pause animation"; top: 95vh; } .content { width: 80vmin; height: 80vmin; background: var(--bg); display: flex; align-items: center; justify-content: center; gap: 2vmin; perspective-origin: 50% 50%; perspective: 100vmin; position: absolute; transition: all 0.33s ease 0s; } .cuboids { display: flex; align-items: center; justify-content: center; flex-direction: row-reverse; gap: 2vmin; } .cuboid { --height: 15; --width: 3; --depth: 6; --hue: 300; --sat: 8%; height: calc(var(--height)* 1vmin); width: calc(var(--width)* 1vmin); transform: translateZ(calc(-3vmin + 1px)); animation: leaping var(--sp) var(--ttf) 0s infinite alternate; } @keyframes leaping { 100% { transform: translateZ(3vmin); } } .cuboid .side { position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; border-radius: 2px; background: hsl(var(--hue), var(--sat), 10%); } .cuboid .side:nth-of-type(1) { transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin)); border-top: 1px solid hsl(var(--hue), var(--sat), 50%); animation: lights var(--sp) var(--ttf) 0s infinite alternate; background: linear-gradient(0deg, hsl(var(--hue), var(--sat), 25%), hsl(var(--hue), var(--sat), 55%)); background-size: 100% 300%; } @keyframes lights { 0% { background-position: 0 100%; } 100% { background-position: 0 0%; } } .cuboid .side:nth-of-type(2) { transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin)) rotateY(180deg); } .cuboid .side:nth-of-type(3) { width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateY(90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin)); } .cuboid .side:nth-of-type(4) { width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateY(-90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin)); } .cuboid .side:nth-of-type(5) { height: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin)); } .cuboid .side:nth-of-type(6) { height: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(-90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin)); } .cuboid:nth-child(2), .cuboid:nth-child(2) .side, .shadows div:nth-child(2) { animation-delay: calc(var(--dy) * -1); } .cuboid:nth-child(3), .cuboid:nth-child(3) .side, .shadows div:nth-child(3) { animation-delay: calc(var(--dy) * -2); } .cuboid:nth-child(4), .cuboid:nth-child(4) .side, .shadows div:nth-child(4) { animation-delay: calc(var(--dy) * -3); } .cuboid:nth-child(5), .cuboid:nth-child(5) .side, .shadows div:nth-child(5) { animation-delay: calc(var(--dy) * -4); } .cuboid:nth-child(6), .cuboid:nth-child(6) .side, .shadows div:nth-child(6) { animation-delay: calc(var(--dy) * -5); } .cuboid:nth-child(7), .cuboid:nth-child(7) .side, .shadows div:nth-child(7) { animation-delay: calc(var(--dy) * -6); } .cuboid:nth-child(8), .cuboid:nth-child(8) .side, .shadows div:nth-child(8) { animation-delay: calc(var(--dy) * -7); } .shadows { position: absolute; display: flex; align-items: center; justify-content: center; flex-direction: row-reverse; gap: 2vmin; } .shadows div { background: #0000; width: 3vmin; height: 15vmin; box-shadow: 0 0vmin 0.1vmin 0.1vmin #0008, 0 0vmin 0.5vmin 0 #0008, 0 0vmin 1vmin 1.5vmin #0008 inset; animation: shadow-leaping var(--sp) var(--ttf) 0s infinite alternate; filter: blur(0.5vmin); } @keyframes shadow-leaping { 100% { box-shadow: 0 2vmin 2vmin 0 #0008; } } @keyframes shadow-leaping { 100% { height: 18vmin; margin-top: 2.5vmin; box-shadow: 0 0vmin 4vmin -0.2vmin #000, 0 0vmin 0.5vmin 0 #0008, 0 0vmin 1vmin 1.5vmin.........完整代码请登录后点击上方下载按钮下载查看
网友评论0