css实现开箱动画
代码语言:html
所属分类:布局界面
代码描述:css实现开箱动画
代码标签: 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --dur: 2s; --bg: #e3e4e8; --fg: #17181c; font-size: calc(12px + (24 - 12)*(100vw - 320px)/(2560 - 320)); } body { background: var(--bg); color: var(--fg); display: flex; font: 1em/1.5 sans-serif; height: 100vh; overflow: hidden; } .preloader, .box, .box__inner, .box__inner div { transform-style: preserve-3d; } .preloader { margin: auto; position: relative; width: 12em; height: 24em; } .box, .box__inner, .box__inner div, .line { position: absolute; } .box, .box__inner div, .line__inner { animation-timing-function: ease-in-out; animation-iteration-count: infinite; } .box, .line__inner { animation-duration: var(--dur); } .box__inner div, .line__inner { background: var(--fg); } /* Boxes */ .box, .box__inner { width: 100%; height: 50%; } .box { animation-name: popOut; top: 50%; perspective: 25em; transform-origin: 50% 75%; z-index: 1; } .box + .box { animation-delay: calc(var(--dur)/-2); } .box__inner, .box__inner div { animation-delay: inherit; animation-duration: inherit; } .box__inner { transform: rotateX(50deg); transform-origin: 50% 25%; } .box__inner div { box-shadow: 0 0 0 0.2em var(--bg) inset; } .box__back-flap, .box__front-flap, .box__front { width: 6em; } .box__left-flap, .box__right-flap, .box__front { height: 6em; } .box__back-flap, .box__front-flap { left: 3em; height: 3em; } .box__left-flap, .box__right-flap { top: 3em; width: 3em; } .box__back-flap { animation-name: backFlap; transform: rotateX(-180deg); transform-origin: 50% 100%; } .box__right-flap { animation-name: rightFlap; left: 9em; transform: rotateY(-179deg); transform-origin: 0 50%; } .box__front-flap { animation-name: frontFlap; top: 9em; transform: rotateX(180deg); transform-origin: 50% 0; } .box__left-flap { animation-name: leftFlap; transform: rotateY(179deg); transform-origin: 100% 50%; } .box__front { top: 3em; left: 3em; transform: rotateX(-90deg) translateY(50%) translateZ(3em); } /* Lines */ .line, .line__inner { border-radius: 0.1em; } .line { top: 0; left: calc(50% - 0.1em); width: 0.2em; height: 6em; overflow: hidden; transform-origin: 50% 0.1em; } .line:nth-child(n + 5) { top: 90%; transform: translateY(2em); } .line:nth-child(3) { left: calc(50% - 1.1em); } .line:nth-child(4) { left: calc(50% + 0.9em); } .line:nth-child(5) { transform: rotate(-90deg) translateY(2em); } .line:nth-child(6) { transform: rotate(-45deg); } .line:nth-child(7) { transform: translateY(-0.5em); } .line:nth-child(8) { transform: rotate(45deg); } .line:nth-child(9) { transform: rotate(90deg) translateY(2em); } .line__inner { animation-duration: calc(var(--dur)/2); width: 100%; height: 100%; } .line:nth-child(n + 3):nth-child(-n + 4) .line__inner { animation-name: falling; } .line:nth-child(n + 5):nth-child(-n + 9) .line__inner { animation-name: landing; transform: translateY(-100%); } /* Dark Mode */ @media (prefers-color-scheme: da.........完整代码请登录后点击上方下载按钮下载查看
网友评论0