css实现三维可爱烤面包机动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现三维可爱烤面包机动画效果代码,鼠标悬浮点击试试。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, *:after, *:before { box-sizing: border-box; } body { min-height: 100vh; background: #a3bac2; overflow: hidden; margin: 0; padding: 0; } :root { --toaster-width: 18; --toaster-height: 10; --toaster-depth: 12; --toast-depth: 1; --eye-size: 1.75vmin; --feature: #0d0d0d; --shadow: #404040; --cloth-color-one: rgba(204,51,153,0.65); --speed: 1; --transition: 0.25; --handle: #333; --shade-one: #d9d9d9; --shade-two: #bfbfbf; --shade-three: #a6a6a6; --shine: rgba(255,255,255,0.5); } [type='checkbox'] { position: absolute; left: 100%; opacity: 0; height: 0; width: 0; } .rotater { position: fixed; height: 10vmin; width: 100vmax; top: 0; left: 0; z-index: 2; } .rotater:hover ~ .scene .plane { -webkit-animation: spin-y 1s infinite linear; animation: spin-y 1s infinite linear; } .rotater--bottom { transform: translate(0, calc(100vh - 10vmin)); } .rotater--bottom:hover ~ .scene .plane { animation: spin-y 1s infinite reverse linear; } .rotater--left { transform: rotate(90deg); transform-origin: 0 100%; } .rotater--left:hover ~ .scene .plane { animation: spin-x 1s infinite reverse linear; } .rotater--right { transform: rotate(90deg) translate(0, calc(-100vw + 10vmin)); transform-origin: 0 100%; } .rotater--right:hover ~ .scene .plane { -webkit-animation: spin-x 1s infinite linear; animation: spin-x 1s infinite linear; } .scene { perspective: 800px; transform-style: preserve-3d; height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: center; } .plane { height: 20vmin; width: 40vmin; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-24deg) rotateX(90deg); } .cube { --width: 15; --height: 10; --depth: 4; height: calc(var(--depth) * 1vmin); width: calc(var(--width) * 1vmin); transform-style: preserve-3d; position: absolute; font-size: 1rem; -webkit-animation: spin 1s infinite linear; animation: spin 1s infinite linear; transform: translate3d(0, 0, 5vmin); } .cube > div:nth-of-type(1) { height: calc(var(--height) * 1vmin); width: 100%; transform-origin: 50% 50%; transform: rotateX(-90deg); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotateX(-90deg) translate3d(0, 0, calc((var(--depth) / 2) * 1vmin)); } .cube > div:nth-of-type(2) { height: calc(var(--height) * 1vmin); width: 100%; transform-origin: 50% 50%; transform: translate(-50%, -50%) rotateX(-90deg) rotateY(180deg) translate3d(0, 0, calc((var(--depth) / 2) * 1vmin)); position: absolute; top: 50%; left: 50%; } .cube > div:nth-of-type(3) { height: calc(var(--height) * 1vmin); width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(-90deg) rotateY(90deg) translate3d(0, 0, calc((var(--width) / 2) * 1vmin)); position: absolute; top: 50%; left: 50%; } .cube > div:nth-of-type(4) { height: calc(var(--height) * 1vmin); width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(-90deg) rotateY(-90deg) translate3d(0, 0, calc((var(--width) / 2) * 1vmin)); position: absolute; top: 50%; left: 50%; } .cube > div:nth-of-type(5) { .........完整代码请登录后点击上方下载按钮下载查看
网友评论0