js实现三维数据方块效果代码

代码语言:html

所属分类:三维

代码描述:js实现三维数据方块效果代码

代码标签: js 三维 数据 方块

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


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

<head>

  <meta charset="UTF-8">
  
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;700&display=swap" rel="stylesheet">


  
  
<style>
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #2e3440;
  transform: translateZ(0);
  font-family: Nunito, Arial, sans-serif;
}
#stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: -webkit-grab;
  cursor: grab;
}
#stage:active {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}
#checkbox {
  display: none;
  visibility: hidden;
  opacity: 0;
}
#checkbox:checked + .toggle {
  background: #5e81ac;
}
#checkbox:checked + .toggle:before {
  content: "Show Active Bits";
}
#checkbox:not(:checked) + .toggle {
  background: #b48ead;
}
#checkbox:not(:checked) + .toggle:before {
  content: "Show Inactive Bits";
}
.toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  padding: 8px 16px;
  border-radius: 99999px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}
.container {
  position: relative;
  transform-style: preserve-3d;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  will-change: transform;
}
.box {
  position: absolute;
  transform-style: preserve-3d;
}
.box:nth-child(0) .face {
  opacity: 0.75;
}
.box .face {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  border: 2px solid currentColor;
  background: #d8dee9;
  color: #434c5e;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  outline: 1px transparent;
  font-weight: bold;
  font-size: 1.25rem;
/* Front & Back */
/* Left & Right */
/* Top & Bottom */
}
.box .face.empty {
  opacity: 0;
}
.box .face.horizontal-line {
  background: #8fbcbb;
}
.box .face.vertical-line {
  background: #88c0d0;
}
.box .face.cube {
  background: #bf616a;
}
.box .face:nth-child(1) {
  transform: translateZ(calc(var(--scale) * 0.5px));
}
.box .face:nth-child(2) {
  transform: translateZ(calc(var(--scale) * -0.5px)) rotateY(180deg);
}
.box .face:nth-child(3) {
  transform: rotateY(-90deg) translateZ(calc(var(--scale) * 0.5px));
}
.box .face:nth-child(4) {
  transform: rotateY(-90deg) translateZ(calc(var(--scale) * -0.5px)) rotateY(180deg);
}
.box .face:nth-child(5) {
  transform: rotateX(-90deg) translateZ(calc(var(--scale) * 0.5px));
}
.box .face:nth-child(6) {
  transform: rotateX(-90deg) trans.........完整代码请登录后点击上方下载按钮下载查看

网友评论0