div+css实现磨砂玻璃立方体旋转动画效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现磨砂玻璃立方体旋转动画效果代码

代码标签: div css 磨砂 玻璃 立方体 旋转 动画

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

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

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



  
  
<style>
:root {
  --item-size: 28vmin;
  --depth: 1;
}

.bg-image {
  background: url("//repo.bfw.wiki/bfwrepo/image/66a2cc1f5b1d6.png") center center no-repeat;
  background-position: cover;
  position: absolute;
  inset: -20vmin;
  -webkit-animation: zoom-in-out 20s ease infinite;
          animation: zoom-in-out 20s ease infinite;
}

@-webkit-keyframes zoom-in-out {
  from {
    transform: scale(1.1) translateX(-2vmin);
  }
  50% {
    transform: scale(1) translateX(2vmin);
  }
  to {
    transform: scale(1.1) translateX(-2vmin);
  }
}

@keyframes zoom-in-out {
  from {
    transform: scale(1.1) translateX(-2vmin);
  }
  50% {
    transform: scale(1) translateX(2vmin);
  }
  to {
    transform: scale(1.1) translateX(-2vmin);
  }
}
.face {
  position: relative;
  aspect-ratio: 1;
  border-radius: 1rem;
  padding: rem;
  transform-style: preserve-3d;
}

.bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  -webkit-backdrop-filter: blur(0.2rem) brightness(1.1) saturate(1.01);
          backdrop-filter: blur(0.2rem) brightness(1.1) saturate(1.01);
  transform-style: preserve-3d;
}
.bg.second {
  inset: 0.1vmin;
  -webkit-backdrop-filter: blur(0.5rem) brightness(1.32);
          backdrop-filter: blur(0.5rem) brightness(1.32);
  transform-style: preserve-3d;
}

.content {
  position: absolute;
  inset: 2vmin;
  display: flex;
  transform-style: preserve-3d;
  opacity: 0.4;
  -webkit-backdrop-filter: blur(1.24rem) brightness(1.32);
          backdrop-filter: blur(1.24rem) brightness(1.32);
}

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

@keyframes cube-animation {
  from {
    transform: rotate3d(1, 0, 1, 0deg);
  }
  to {
    transform: rotate3d(1, 0, 1, 360deg);
  }
}
.cube {
  position: relative;
  --width: var(--item-size);
  --width-n: calc(var(--item-size) * -1);
  --height: calc(var(--item-size) * var(--depth));
  --height-half: calc(var(--height) / 2);
  --height-half-n: calc(var(--height) / -2);
  width: var(--width);
  height: var(--width);
  --offset-per-item: calc(
    360deg / (var(--count) + 17 + var(--ring-index) * 5.5)
  );
  --angle: calc(var(--offset-per-item) * var(--item-index));
  --radius: calc(var(--inner-radius) + (var(--ring-gap) * var(--ring-index)));
  --x: calc(cos(var(--angle)) * var(--radius));
  --y: calc(sin(var(--angle)) * var(--radius));
  transform: translate3d(var(--x), var(--y), 0) rotate3d(0, 0, 1, var(--angle));
  transform-style: preserve-3d;
  transform-origin: var(--pos);
  -webkit-animation: cube-animation 5s linear infinite;
          animation: cube-animation 5s linear infinite;
}
.cub.........完整代码请登录后点击上方下载按钮下载查看

网友评论0