css实现三维分层盒子模型演示动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现三维分层盒子模型演示动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> .stack { display: grid; grid: [stack] / [stack]; perspective: 5000 } .stack:before { content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgb(240, 240, 240); transition: background 2s ease; pointer-events: none; } .stack:hover:before, .stack:active:before { background: rgb(37, 37, 37); } .stack:hover .card, .stack:active .card { --bg-opacity: 5%; transition-duration: 2s; transition-timing-function: var(--easeInOutCirc); transform: rotateX(45deg) rotate(45deg) translateZ(var(--z-offset)) translateY(20vh) translateX(20vh) } .stack:hover .card:nth-child(1), .stack:active .card:nth-child(1) { --z-offset: 75vh; } .stack:hover .card:nth-child(2), .stack:active .card:nth-child(2) { --z-offset: 50vh; } .stack:hover .card:nth-child(3), .stack:active .card:nth-child(3) { --z-offset: 25vh; } .stack:hover .card:nth-child(4), .stack:active .card:nth-child(4) { --z-offset: 0vh; } .stack:hover .card:nth-child(5), .stack:active .card:nth-child(5) { --z-offset: -25vh; } .stack:hover .card:nth-child(1)::after, .stack:active .card:nth-child(1)::after { transition-delay: 1.5s; } .stack:hover .card:nth-child(2)::after, .stack:active .card:nth-child(2)::after { transition-delay: 1.7s; } .stack:hover .card:nth-child(3)::after, .stack:active .card:nth-child(3)::after { transition-delay: 1.9s; } .stack:hover .card:nth-child(4)::after, .stack:active .card:nth-child(4)::after { transition-delay: 2.1s; } .stack:hover .card:nth-child(5)::after, .stack:active .card:nth-child(5)::after { transition-delay: 2.3s; } .stack:hover .card::after, .stack:active .card::after { opacity: 1; transform: rotate(-45deg) rotateY(45deg) translateX(0px); } .stack:hover .card.content, .stack:active .card.content { background: transparent; color: white; border-color: transparent; transition: border-color 1s var(--easeInOutCirc) 0s, background-color 1s var(--easeInOutCirc) 0s, color 1s var(--easeInOutCirc) 0s, transform 2s var(--easeInOutCirc) 0s; } .stack:hover .card.padding, .stack:active .card.padding { transition-delay: .1s; } .stack:hover .card.border, .stack:active .card.border { transition-delay: .2s; } .stack:hover .card.background, .stack:active .card.background { background: white; transition: background-color 2s var(--easeInOutCirc) .3s, transform 2s var(--easeInOutCirc) .2s; } .stack:hover .card.box-shadow, .stack:active .card.box-shadow { transition-delay: .4s; box-shadow: 0 -1px 25px rgba(0, 0, 0, 0.4), 0 7.6px 6.1px rgba(0, 0, 0, 0.051), 0 14.3px 11.5px rgba(0, 0, 0, 0.059), 0 25.5px 20.5px rgba(0, 0, 0, 0.07), 0 47.6px 38.4px rgba(0, 0, 0, 0.094), 0 114px 92px rgba(0, 0, 0, 0.19) ; } .card { grid-area: stack; --z-offset: 0; --easeInOutCirc: cubic-bezier(0.85, 0, 0.15, 1); --bg-opacity: 0%; transition: transform 4s ease; width: 40vmin; height: 40vmin; box-sizing: border-box; color: white; box-siing: border-box; background: rgba(255, 255, 254, 0.05); position: relative } @media (orientation: landscape) { .card { width: 40vh; height: 40vh } } @media (max-width: 540px) { .card { width: 60vw; height: 60vw } } .card:nth-child(1) { z-index: 3; } .card:nth-child(2) { z-index: 2; } .card::after { content: "Box"; position: absolute; left: -45%; top: 110%; font-size: 1.25rem; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75); white-space: nowrap; padding: 1ch 2ch; border-radius: 4ch; opacity: 0; transition: opacity .5s ease 0s, transform .5s ease; transform: rotate(-45deg) rotateY(45deg) translateX(20px); background: rgba(0, 0, 0, 0.7) } @media (max-width: 540px) { .card::after { left: -20%; top: 7.........完整代码请登录后点击上方下载按钮下载查看
网友评论0