js+css实现键盘立体可视化数字滚动页面翻转动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:js+css实现键盘立体可视化数字滚动页面翻转动画效果代码

代码标签: js css 键盘 立体 可视化 数字 滚动 页面 翻转 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
@property --rotate-x {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}
@property --scene-rotation {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}
@property --key-color {
  syntax: "<color>";
  inherits: true;
  initial-value: transparent;
}
@property --foo {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
:root {
  --color-primary: #5c4293;
  --color-secondary: #dd6058;
  --color-tertiary: #cfa469;
  --color-quaternary: #27235a;
  --color-surface: black;
  --key-depth: 4rem;
  --key-width: 4rem;
  --key-height: 5rem;
  --key-height-delta: 0rem;
  --key-color: rgba(255, 255, 255, 0.6);
}

body {
  color: var(--color-primary);
  background: url("//repo.bfw.wiki/bfwrepo/image/6701d58fdb581.png") center center no-repeat, #1f1f20;
  background-size: cover;
  background-attachment: fixed;
  margin: 0;
  font-family: "Road Rage", "Helvetica Neue", Roboto, "sans-serif";
}
body:after {
  height: 100dvh;
  content: "";
  position: fixed;
  background: url(//repo.bfw.wiki/bfwrepo/icon/5de90f964d501.png);
  mix-blend-mode: overlay;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
  filter: invert(1);
  z-index: 0;
}

a.labs-follow-me {
  left: 2rem;
  right: 2rem;
  bottom: 1rem;
  top: unset;
  text-align: center;
}

@-webkit-keyframes rotate360 {
  from {
    transform: rotate3d(1, 1, 1, 0deg);
  }
  to {
    transform: rotate3d(1, 1, 1, 360deg);
  }
}

@keyframes rotate360 {
  from {
    transform: rotate3d(1, 1, 1, 0deg);
  }
  to {
    transform: rotate3d(1, 1, 1, 360deg);
  }
}
@-webkit-keyframes scene-rotation {
  from {
    --scene-rotation: -5deg;
  }
  50% {
    --scene-rotation: 12deg;
  }
  to {
    --scene-rotation: -5deg;
  }
}
@keyframes scene-rotation {
  from {
    --scene-rotation: -5deg;
  }
  50% {
    --scene-rotation: 12deg;
  }
  to {
    --scene-rotation: -5deg;
  }
}
.scene {
  transform-style: preserve-3d;
  position: absolute;
  transition: transform 0.1s linear;
  transform: rotateX(calc(21deg - var(--rotate-x, 0deg))) rotateY(var(--scene-rotation));
}

:root {
  -ms-scroll-snap-type: y mandatory;
      scroll-snap-type: y mandatory;
}

.views .item {
  font-size: 14rem;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  height: 100dvh;
  width: 100dvw;
  text-shadow: 0 0 1rem #d4bee8;
  color: white;
  -webkit-animation: show linear both;
          animation: show linear both;
  animation-timeline: --bubu;
  animation-range: entry-crossing 0% exit-crossing 100%;
  view-timeline: --bubu block;
}

.layers {
  position: fixed;
  z-index: 2;
  top: 50dvh;
  font-size: 25dvh;
  left: 0;
  right: 0;
  text-align: center;
  -webkit-animation: slide-up 0.01s linear;
          animation: slide-up 0.01s linear;
  animation-timeline: scroll(root block);
  --num-children: 6;
  --size-per-child: calc(100% / var(--num-children));
  --half-size-per-child: calc(var(--size-per-child) / 2);
  --start-pos: calc(var(--half-size-per-child) * -1);
  --end-pos: calc(-100% + var(--half-size-per-child));
  translate: 0 var(--start-pos);
}
.layers .item {
  height: 2rem;
  color: white;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  transition: transform 0.6s linear;
  transform: translate3d(0, 30dvh, -400rem) perspective(27rem) scale(0.2);
  --foo: 0.8;
  --rotate-x: -50deg;
}
.layers .item.before {
  transform: translate3d(0, -30dvh, -400rem) perspective(27rem) scale(0.2);
  --rotate-x: -50deg;
}
.layers .item.active {
  --foo: 0;
  transform: translate3d(0, 0, 0rem) perspective(27rem) scale(1);
  --rotate-x: -1deg;
}
.layers .item.active .scene {
  -webkit-animation: 10s ease-in-out scene-rotation infinite;
          animation: 10s ease-in-out scene-rotation infinite;
}

@property --key-height-delta {
  syntax: "<length>";
  initial-value: 0;
  inherits: true;
}
.container {
  width: var(--width);
  height: var(--width);
  transform-style: preserve-3d;
  position: relative;
  transform: rotate3d(1, 0, 0, -90deg);
}
.container .face {
  transform-style: preserve-3d;
  position: absolute;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  background: radial-gradient(circle at 50% -40%, var(--key-color), transparent 80%);
  border-radius: 0 0 var(--key-radius) var(--key-radius);
  opacity: 0.5;
}
.container .face.front {
  width: var(--width);
  height: calc(var(--height) - var(--key-height-delta));
  transform: translate3d(0, var(--key-height-delta), var(--depth-half));
}
.container .face.back {
  width: var(--width);
  height: calc(var(--height) - var(--key-height-delta));
  transform: rotate3d(0, 1, 0, 180deg) translate3d(0, var(--key-height-delta), var(--depth-half));
}
.container .face.left {
  width: var(--depth);
  height: calc(var(--height) - var(--key-height-delta));
  transform: rotate3d(0, 1, 0, -90deg) translate3d(0, var(--key-height-delta), var(--width-half));
}
.container .face.right {
  width: var(--depth);
  height: calc(var(--height) - var(--key-height-delta));
  transform: rotate3d(0, 1, 0, 90deg) translate3d(0, var(--key-height-delta), var(--width-half));
}
.container .face.top {
  width: var(--width);
  height: var(--depth);
  color: white;
  --key-color: rgba(255, 255, 255, 0.2);
  transform: rotate3d(1, 0, 0, 90deg) translate3d(0, 0, calc(var(--width-half) - var(--key-height-delta)));
  border-radius: var(--key-radius);
  border: 1px solid rgba(255, 255, 255, 0.13);
  opacity: 1;
  text-shadow: -1px -1px rgba(0, 0, 0, 0.3);
  background: radial-gradient(120% 120% at center, transparent, var(--key-color));
}

labs-key {
  display: block;
  --key-radius: 0.5rem;
  --width: var(--key-width, 4rem);
  --depth: var(--key-depth, 4rem);
  --height: var(--key-height, 1rem);
  --width-half: calc(var(--width) / 2);
  --width-half-n: calc(var(--width) / -2);
  --depth-half: calc(var(--depth) / 2);
  --depth-half-n: calc(var(--depth) / -2);
  --width-n: calc(var(--width) * -1);
  --height-half: calc(var(--height) / 2);
  --height-half-n: calc(var(--height) / -2);
  position: relative;
  transform-style: preserve-3d;
  width: var(--width);
  height: var(--depth);
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}
labs-key.keypress {
  --key-height-delta: 0;
  -webkit-animation: keypress 0.1s ease forwards;
          animation: keypress 0.1s ease forwards;
}

@-webkit-keyframes keypress {
  from {
    --key-height-delta: 0rem;
  }
  to {
    --key-height-delta: calc(var(--key-height) * 0.3);
  }
}

@keyframes keypress {
  from {
    --key-height-delta: 0rem;
  }
  to {
    --key-height-delta: calc(var(--key-height) * 0.3);
  }
}
.keyboard {
  transform-style: preserve-3d;
  padding: 1rem 1rem 6rem 1rem;
  border-radius: 0.5rem;
  display: flex;
  gap: calc(var(--key-width) * 2 + 2rem);
}
.keyboard:after {
  transform-style: flat;
  background: #333;
  background: rgba(255, 255, 255, 0.08);
  background: linear-gradient(288deg, #e8d1a047, transparent);
  content: "";
  z-index: -1;
  position: absolute;
  inset: 0;
  --c1: 31%;
  -webkit-mask-image: radial-gradient(82% 129% at 22% 40%, black var(--c1), transparent var(--c1)), radial-gradient(82% 129% at 78% 40%, black var(--c1), transparent var(--c1)), linear-gradient(to bottom, transparent 30%, black 30%), radial-gradient(126% 129% at 6% 118%, black var(--c1), transparent var(--c1)), radial-gradient(126% 129% at.........完整代码请登录后点击上方下载按钮下载查看

网友评论0