div+css实现折叠的方块彩色纸片循环动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现折叠的方块彩色纸片循环动画效果代码
代码标签: div css 折叠 方块 彩色 纸片 循环 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, *::before, *::after { padding: 0; margin: 0 auto; box-sizing: border-box; } body { background-color: #000; color: #fff; min-height: 100vh; display: grid; place-items: center; perspective: 800px; overflow: hidden; *:not(:empty) { transform-style: preserve-3d; } } .scene { position: relative; transform: rotateX(60deg) rotateZ(20deg); --duration: 3s; } .floor { position: absolute; inset: -20em -40em; background-color: #333; background-image: radial-gradient(#0000, #000 70%), repeating-linear-gradient(0deg, #fff1 0 1em, #fff2 0 4em), repeating-linear-gradient(90deg, #fff1 0 1em, #fff2 0 4em); -webkit-animation: floor var(--duration) infinite linear; animation: floor var(--duration) infinite linear; } @-webkit-keyframes floor { from { background-position-x: 0, 0, -0.5em; } to { background-position-x: 0, 0, -20.5em; } } @keyframes floor { from { background-position-x: 0, 0, -0.5em; } to { background-position-x: 0, 0, -20.5em; } } .shadow { position: absolute; i { position: absolute; inset: calc(-0.2em - 1em * var(--i)); -webkit-animation-name: shadowTranslate, shadowOpacity; animation-name: shadowTranslate, shadowOpacity; -webkit-animation-duration: var(--duration); animation-duration: var(--duration); -webkit-animation-delay: calc(var(--i) * var(--duration) * 0.05 - var(--duration) * 1.5); animation-delay: calc(var(--i) * var(--duration) * 0.05 - var(--duration) * 1.5); -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; -webkit-animation-timing-function: linear; animation-timing-function: linear; box-shadow: 0 0 0.8em 0.8em #000, 0 0 0.8em 0.8em #000 inset; } } @-webkit-keyframes shadowTranslate { from { translate: calc(-1em * var(--i) + 10em); } to { translate: calc(-1em * var(--i) - 10em); } } @keyframes shadowTranslate { from { translate: calc(-1em * var(--i) + 10em); } to { translate: calc(-1em * var(--i) - 10em); } } @-webkit-keyframes shadowOpacity { 0%, 25%, 75%, 100% { opacity: 0; } 50% { opacity: 1; } } @keyframes shadowOpacity { 0%, 25%, 75%, 100% { opacity: 0; } 50% { opacity: 1; } } .squares { position: absolute; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0