纯css三维方块缩放动画效果代码
代码语言:html
所属分类:动画
代码描述:纯css三维方块缩放动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; } html, body { height: 100%; } body { display: grid; place-items: center; background-color: hsl(0, 0%, 10%); overflow: hidden; } main { -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transform: rotateX(45deg) rotateZ(45deg); transform: rotateX(45deg) rotateZ(45deg); } .cube { --size: 3rem; --offset: calc(var(--size) * -1); --duration: 3600ms; --delay: calc(var(--i) * -0.0335s); --ease: cubic-bezier(0.84, 0, 0.2, 1); position: relative; display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; margin: 1rem; width: var(--size); height: var(--size); background-color: var(--bg-color); box-shadow: inset rgba(black, 0.15) -0.5rem 0.5rem 1rem; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transform-origin: 50% 100% var(--offset); transform-origin: 50% 100% var(--offset); -webkit-transition-property: background-color, -webkit-transform; transition-property: background-color, -webkit-transform; transition-property: transform, background-color; transition-property: transform, background-color, -webkit-transform; -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out; -webkit-animation: animate var(--duration) var(--delay) var(--ease) alternate infinite, color calc(var(--duration) * 2) var(--delay) var(--ease) infinite; animation: animate var(--duration) var(--delay) var(--ease) alternate infinite, color calc(var(--duration) * 2) var(--delay) var(--ease) infinite; } .cube:nth-child(odd) { --bg-color: hsl(0, 54%, 61%); } .cube:nth-child(even) { --bg-color: hsl(59, 94%, 57%); } .cube:nth-child(3n) { --bg-color: hsl(230, 92%, 61%); } .cube::before, .cube::after { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: inherit; box-shadow: inherit; -webkit-transform-origin: 100% 100%; transform-origin: 100% 100%; } .cube::before { -webkit-transform: translateZ(var(--offset)) rotateY(90deg); transform: translateZ(var(--offset)) rotateY(90deg); -webkit-filter: brightness(120%); filter: brightness(120%); } .cube::after { -webkit-transform: translateZ(var(--offset)) rotateX(-90deg); transform: translateZ(var(--offset)) rotateX(-90deg); -webkit-filter: brightness(80%); filter: brightness(80%); } @-webkit-keyframes animate { 0% { -webkit-transform: scaleX(4); transform: scaleX(4); } 20% { -webkit-transform: scaleX(0.5) sc.........完整代码请登录后点击上方下载按钮下载查看
网友评论0