js+div实现三维方块彩色立方体随机生成效果代码
代码语言:html
所属分类:三维
代码描述:js+div实现三维方块彩色立方体随机生成效果代码
代码标签: js div 三维 方块 彩色 立方体 随机 生成
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: grid; place-items: center; height: 100vh; filter: none; --width: 100px; --mouseX: 0; --mouseY: 0; --translate: 0%, 0%; --scale: 1; --scale-2: 1; background: #ece9ea; cursor: pointer; } body:before { content: "click & hover"; font-family: "Futura", sans-serif; position: absolute; bottom: 10px; font-size: 10px; } body #wrap { filter: drop-shadow(1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 -1px 0 #000) drop-shadow(1px 1px 0 #000) drop-shadow(1px -1px 0 #000) drop-shadow(-1px 1px 0 #000) drop-shadow(-1px -1px 0 #000); position: relative; z-index: 0; width: 100vw; height: 100vh; display: grid; place-items: center; } body #plane { z-index: 0; position: relative; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; transform-style: preserve-3d; transform: scale(calc(0.75 + (var(--mouseY) / 3))) translateY(50px) rotateX(calc(35deg - (var(--mouseY) * -35deg))) rotate(calc(45deg + (var(--mouseX) * 180deg))) rotateY(-180deg); } body .box { width: var(--width); height: var(--width); position: relative; transition: transform 0.3s ease-in-out; transform-style: preserve-3d; transform: translate(var(--translate)) scale3d(calc(var(--scale-1) * 0.125), calc(var(--scale-2) * 0.125), calc(var(--size) * 0.005)); transform-origin: 50% 50% 50%; } body .box:nth-of-type(1) { transition-delay: 0.0166666667s; } body .box:nth-of-type(1) .side:nth-of-type(1):before { transition-delay: 0.175s; } body .box:nth-of-type(1) .side:nth-of-type(2):before { transition-delay: 0.3416666667s; } body .box:nth-of-type(1) .side:nth-of-type(3):before { transition-delay: 0.5083333333s; } body .box:nth-of-type(1) .side:nth-of-type(4):before { transition-delay: 0.675s; } body .box:nth-of-type(1) .side:nth-of-type(5):before { transition-delay: 0.8416666667s; } body .box:nth-of-type(1) .side:nth-of-type(6):before { transition-delay: 1.0083333333s; } body .box:nth-of-type(2) { transition-delay: 0.0333333333s; } body .box:nth-of-type(2) .side:nth-of-type(1):before { transition-delay: 0.1833333333s; } body .box:nth-of-type(2) .side:nth-of-type(2):before { transition-delay: 0.35s; } body .box:nth-of-type(2) .side:nth-of-type(3):before { transition-delay: 0.5166666667s; } body .box:nth-of-type(2) .side:nth-of-type(4):before { transition-delay: 0.6833333333s; } body .box:nth-of-type(2) .side:nth-of-type(5):before { transition-delay: 0.85s; } body .box:nth-of-type(2) .side:nth-of-type(6):before { transition-delay: 1.0166666667s; } body .box:nth-of-type(3) { transition-delay: 0.05s; } body .box:nth-of-type(3) .side:nth-of-type(1):before { transition-delay: 0.1916666667s; } body .box:nth-of-type(3) .side:nth-of-type(2):before { transition-delay: 0.3583333333s; } body .box:nth-of-type(3) .side:nth-of-type(3):before { transition-delay: 0.525s; } body .box:nth-of-type(3) .side:nth-of-type(4):before { transition-delay: 0.6916666667s; } body .box:nth-of-type(3) .side:nth-of-type(5):before { transition-delay: 0.8583333333s; } body .box:nth-of-type(3) .side:nth-of-type(6):before { transition-delay: 1.025s; } body .box:nth-of-type(4) { transition-delay: 0.0666666667s; } body .box:nth-of-type(4) .side:nth-of-type(1):before { transition-delay: 0.2s; } body .box:nth-of-type(4) .side:nth-of-type(2):before { transition-delay: 0.3666666667s; } body .box:nth-of-type(4) .side:nth-of-type(3):before { transition-delay: 0.5333333333s; } body .box:nth-of-type(4) .side:nth-of-type(4):before { transition-delay: 0.7s; } body .box:nth-of-type(4) .side:nth-of-type(5):before { transition-delay: 0.8666666667s; } body .box:nth-of-type(4) .side:nth-of-type(6):before { transition-delay: 1.0333333333s; } body .box:nth-of-type(5) { transition-delay: 0.0833333333s; } body .box:nth-of-type(5) .side:nth-of-type(1):before { transition-delay: 0.2083333333s; } body .box:nth-of-type(5) .side:nth-of-type(2):before { transition-delay: 0.375s; } body .box:nth-of-type(5) .side:nth-of-type(3):before { transition-delay: 0.5416666667s; } body .box:nth-of-type(5) .side:nth-of-type(4):before { transition-delay: 0.7083333333s; } body .box:nth-of-type(5) .side:nth-of-type(5):before { transition-delay: 0.875s; } body .box:nth-of-type(5) .side:nth-of-type(6):before { transition-delay: 1.0416666667s; } body .box:nth-of-type(6) { transition-delay: 0.1s; } body .box:nth-of-type(6) .side:nth-of-type(1):before { transition-delay: 0.2166666667s; } body .box:nth-of-type(6) .side:nth-of-type(2):before { transition-delay: 0.3833333333s; } body .box:nth-of-type(6) .side:nth-of-type(3):before { transition-delay: 0.55s; } body .box:nth-of-type(6) .side:nth-of-type(4):before { transition-delay: 0.7166666667s; } body .box:nth-of-type(6) .side:nth-of-type(5):before { transition-delay: 0.8833333333s; } body .box:nth-of-type(6) .side:nth-of-type(6):before { transition-delay: 1.05s; } body .box:nth-of-type(7) { transition-delay: 0.1166666667s; } body .box:nth-of-type(7) .side:nth-of-type(1):before { transition-delay: 0.225s; } body .box:nth-of-type(7) .side:nth-of-type(2):before { transition-delay: 0.3916666667s; } body .box:nth-of-type(7) .side:nth-of-type(3):before { transition-delay: 0.5583333333s; } body .box:nth-of-type(7) .side:nth-of-type(4):before { transition-delay: 0.725s; } body .box:nth-of-type(7) .side:nth-of-type(5):before { transition-delay: 0.8916666667s; } body .box:nth-of-type(7) .side:nth-of-type(6):before { transition-delay: 1.0583333333s; } body .box:nth-of-type(8) { transition-delay: 0.1333333333s; } body .box:nth-of-type(8) .side:nth-of-type(1):before { transition-delay: 0.2333333333s; } body .box:nth-of-type(8) .side:nth-of-type(2):before { transition-delay: 0.4s; } body .box:nth-of-type(8) .side:nth-of-type(3):before { transition-delay: 0.5666666667s; } body .box:nth-of-type(8) .side:nth-of-type(4):before { transition-delay: 0.7333333333s; } body .box:nth-of-type(8) .side:nth-of-type(5):before { transition-delay: 0.9s; } body .box:nth-of-type(8) .side:nth-of-type(6):before { transition-delay: 1.0666666667s; } body .box:nth-of-type(9) { transition-delay: 0.15s; } body .box:nth-of-type(9) .side:nth-of-type(1):before { transition-delay: 0.2416666667s; } body .box:nth-of-type(9) .side:nth-of-type(2):before { transition-delay: 0.4083333333s; } body .box:nth-of-type(9) .side:nth-of-type(3):before { transition-delay: 0.575s; } body .box:nth-of-type(9) .side:nth-of-type(4):before { transition-delay: 0.7416666667s; } body .box:nth-of-type(9) .side:nth-of-type(5):before { transition-delay: 0.9083333333s; } body .box:nth-of-type(9) .side:nth-of-type(6):before { transition-delay: 1.075s; } body .box:nth-of-type(10) { transition-delay: 0.1666666667s; } body .box:nth-of-type(10) .side:nth-of-type(1):before { transition-delay: 0.25s; } body .box:nth-of-type(10) .side:nth-of-type(2):before { transition-delay: 0.4166666667s; } body .box:nth-of-type(10) .side:nth-of-type(3):before { transition-delay: 0.5833333333s; } body .box:nth-of-type(10) .side:nth-of-type(4):before { transition-delay: 0.75s; } body .box:nth-of-type(10) .side:nth-of-type(5):before { transition-delay: 0.9166666667s; } body .box:nth-of-type(10) .side:nth-of-type(6):before { transition-delay: 1.0833333333s; } body .box:nth-of-type(11) { transition-delay: 0.1833333333s; } body .box:nth-of-type(11) .side:nth-of-type(1):before { transition-delay: 0.2583333333s; } body .box:nth-of-type(11) .side:nth-of-type(2):before { transition-delay: 0.425s; } body .box:nth-of-type(11) .side:nth-of-type(3):before { transition-delay: 0.5916666667s; } body .box:nth-of-type(11) .side:nth-of-type(4):before { transition-delay: 0.7583333333s; } body .box:nth-of-type(11) .side:nth-of-type(5):before { transition-delay: 0.925s; } body .box:nth-of-type(11) .side:nth-of-type(6):before { transition-delay: 1.0916666667s; } body .box:nth-of-type(12) { transition-delay: 0.2s; } body .box:nth-of-type(12) .side:nth-of-type(1):before { transition-delay: 0.2666666667s; } body .box:nth-of-type(12) .side:nth-of-type(2):before { transition-delay: 0.4333333333s; } body .box:nth-of-type(12) .side:nth-of-type(3):before { transition-delay: 0.6s; } body .box:nth-of-type(12) .side:nth-of-type(4):before { transition-delay: 0.7666666667s; } body .box:nth-of-type(12) .side:nth-of-type(5):before { transition-delay: 0.9333333333s; } body .box:nth-of-type(12) .side:nth-of-type(6):before { transition-delay: 1.1s; } body .box:nth-of-type(13) { transition-delay: 0.2166666667s; } body .box:nth-of-type(13) .side:nth-of-type(1):before { transition-delay: 0.275s; } body .box:nth-of-type(13) .side:nth-of-type(2):before { transition-delay: 0.4416666667s; } body .box:nth-of-type(13) .side:nth-of-type(3):before { transition-delay: 0.6083333333s; } body .box:nth-of-type(13) .side:nth-of-type(4):before { transition-delay: 0.775s; } body .box:nth-of-type(13) .side:nth-of-type(5):before { transition-delay: 0.9416666667s; } body .box:nth-of-type(13) .side:nth-of-type(6):before { transition-delay: 1.1083333333s; } body .box:nth-of-type(14) { transition-delay: 0.2333333333s; } body .box:nth-of-type(14) .side:nth-of-type(1):before { transition-delay: 0.2833333333s; } body .box:nth-of-type(14) .side:nth-of-type(2):before { transition-delay: 0.45s; } body .box:nth-of-type(14) .side:nth-of-type(3):before { transition-delay: 0.6166666667s; } body .box:nth-of-type(14) .side:nth-of-type(4):before { transition-delay: 0.7833333333s; } body .box:nth-of-type(14) .side:nth-of-type(5):before { transition-delay: 0.95s; } body .box:nth-of-type(14) .side:nth-of-type(6):before { transition-delay: 1.1166666667s; } body .box:nth-of-type(15) { transition-delay: 0.25s; } body .box:nth-of-type(15) .side:nth-of-type(1):before { transition-delay: 0.2916666667s; } body .box:nth-of-type(15) .side:nth-of-type(2):before { transition-delay: 0.4583333333s; } body .box:nth-of-type(15) .side:nth-of-type(3):before { transition-delay: 0.625s; } body .box:nth-of-type(15) .side:nth-of-type(4):before { transition-delay: 0.7916666667s; } body .box:nth-of-type(15) .side:nth-of-type(5):before { transition-delay: 0.9583333333s; } body .box:nth-of-type(15) .side:nth-of-type(6):before { transition-delay: 1.125s; } body .box:nth-of-type(16) { transition-delay: 0.2666666667s; } body .box:nth-of-type(16) .side:nth-of-type(1):before { transition-delay: 0.3s; } body .box:nth-of-type(16) .side:nth-of-type(2):before { transition-delay: 0.4666666667s; } body .box:nth-of-type(16) .side:nth-of-type(3):before { transition-delay: 0.6333333333s; } body .box:nth-of-type(16) .side:nth-of-type(4):before { transition-delay: 0.8s; } body .box:nth-of-type(16) .side:nth-of-type(5):before { transition-delay: 0.9666666667s; } body .box:nth-of-type(16) .side:nth-of-type(6):before { transition-delay: 1.1333333333s; } body .box:nth-of-type(17) { transition-delay: 0.2833333333s; } body .box:nth-of-type(17) .side:nth-of-type(1):before { transition-delay: 0.3083333333s; } body .box:nth-of-type(17) .side:nth-of-type(2):before { transition-delay: 0.475s; } body .box:nth-of-type(17) .side:nth-of-type(3):before { transition-delay: 0.6416666667s; } body .box:nth-of-type(17) .side:nth-of-type(4):before { transition-delay: 0.8083333333s; } body .box:nth-of-type(17) .side:nth-of-type(5):before { transition-delay: 0.975s; } body .box:nth-of-type(17) .side:nth-of-type(6):before { transition-delay: 1.1416666667s; } body .box:nth-of-type(18) { transition-delay: 0.3s; } body .box:nth-of-type(18) .side:nth-of-type(1):before { transition-delay: 0.3166666667s; } body .box:nth-of-type(18) .side:nth-of-type(2):before { transition-delay: 0.4833333333s; } body .box:nth-of-type(18) .side:nth-of-type(3):before { transition-delay: 0.65s; } body .box:nth-of-type(18) .side:nth-of-type(4):before { transition-delay: 0.8166666667s; } body .box:nth-of-type(18) .side:nth-of-type(5):before { transition-delay: 0.9833333333s; } body .box:nth-of-type(18) .side:nth-of-type(6):before { transition-delay: 1.15s; } body .box:nth-of-type(19) { transition-delay: 0.3166666667s; } body .box:nth-of-type(19) .side:nth-of-type(1):before { transition-delay: 0.325s; } body .box:nth-of-type(19) .side:nth-of-type(2):before { transition-delay: 0.4916666667s; } body .box:nth-of-type(19) .side:nth-of-type(3):before { transition-delay: 0.6583333333s; } body .box:nth-of-type(19) .side:nth-of-type(4):before { transition-delay: 0.825s; } body .box:nth-of-type(19) .side:nth-of-type(5):before { transition-delay: 0.9916666667s; } body .box:nth-of-type(19) .side:nth-of-type(6):before { transition-delay: 1.1583333333s; } body .box:nth-of-type(20) { transition-delay: 0.3333333333s; } body .box:nth-of-type(20) .side:nth-of-type(1):before { transition-delay: 0.3333333333s; } body .box:nth-of-type(20) .side:nth-of-type(2):before { transition-delay: 0.5s; } body .box:nth-of-type(20) .side:nth-of-type(3):before { transition-delay: 0.6666666667s; } body .box:nth-of-type(20) .side:nth-of-type(4):before { transition-delay: 0.8333333333s; } body .box:nth-of-type(20) .side:nth-of-type(5):before { transition-delay: 1s; } body .box:nth-of-type(20) .side:nth-of-type(6):before { transition-delay: 1.1666666667s; } body .box:nth-of-type(21) { transition-delay: 0.35s; } body .box:nth-of-type(21) .side:nth-of-type(1):before { transition-delay: 0.3416666667s; } body .box:nth-of-type(21) .side:nth-of-type(2):before { transition-delay: 0.5083333333s; } body .box:nth-of-type(21) .side:nth-of-type(3):before { transition-delay: 0.675s; } body .box:nth-of-type(21) .side:nth-of-type(4):before { transition-delay: 0.8416666667s; } body .box:nth-of-type(21) .side:nth-of-type(5):before { transition-delay: 1.0083333333s; } body .box:nth-of-type(21) .side:nth-of-type(6):before { transition-delay: 1.175s; } body .box:nth-of-type(22) { transition-delay: 0.3666666667s; } body .box:nth-of-type(22) .side:nth-of-type(1):before { transition-delay: 0.35s; } body .box:nth-of-type(22) .side:nth-of-type(2):before { transition-delay: 0.5166666667s; } body .box:nth-of-type(22) .side:nth-of-type(3):before { transition-delay: 0.6833333333s; } body .box:nth-of-type(22) .side:nth-of-type(4):before { transition-delay: 0.85s; } body .box:nth-of-type(22) .side:nth-of-type(5):before { transition-delay: 1.0166666667s; } body .box:nth-of-type(22) .side:nth-of-type(6):before { transition-delay: 1.1833333333s; } body .box:nth-of-type(23) { transition-delay: 0.3833333333s; } body .box:nth-of-type(23) .side:nth-of-type(1):before { transition-delay: 0.3583333333s; } body .box:nth-of-type(23) .side:nth-of-type(2):before { transition-delay: 0.525s; } body .box:nth-of-type(23) .side:nth-of-type(3):before { transition-delay: 0.6916666667s; } body .box:nth-of-type(23) .side:nth-of-type(4):before { transition-delay: 0.8583333333s; } body .box:nth-of-type(23) .side:nth-of-type(5):before { transition-delay: 1.025s; } body .box:nth-of-type(23) .side:nth-of-type(6):before { transition-delay: 1.1916666667s; } body .box:nth-of-type(24) { transition-delay: 0.4s; } body .box:nth-of-type(24) .side:nth-of-type(1):before { transition-delay: 0.3666666667s; } body .box:nth-of-type(24) .side:nth-of-type(2):before { transition-delay: 0.5333333333s; } body .box:nth-of-type(24) .side:nth-of-type(3):before { transition-delay: 0.7s; } body .box:nth-of-type(24) .side:nth-of-type(4):before { transition-delay: 0.8666666667s; } body .box:nth-of-type(24) .side:nth-of-type(5):before { transition-delay: 1.0333333333s; } body .box:nth-of-type(24) .side:nth-of-type(6):before { transition-delay: 1.2s; } body .box:nth-of-type(25) { transition-delay: 0.4166666667s; } body .box:nth-of-type(25) .side:nth-of-type(1):before { transition-delay: 0.375s; } body .box:nth-of-type(25) .side:nth-of-type(2):before { transition-delay: 0.5416666667s; } body .box:nth-of-type(25) .side:nth-of-type(3):before { transition-delay: 0.7083333333s; } body .box:nth-of-type(25) .side:nth-of-type(4):before { transition-delay: 0.875s; } body .box:nth-of-type(25) .side:nth-of-type(5):before { transition-delay: 1.0416666667s; } body .box:nth-of-type(25) .side:nth-of-type(6):before { transition-delay: 1.2083333333s; } body .box:nth-of-type(26) { transition-delay: 0.4333333333s; } body .box:nth-of-type(26) .side:nth-of-type(1):before { transition-delay: 0.3833333333s; } body .box:nth-of-type(26) .side:nth-of-type(2):before { transition-delay: 0.55s; } body .box:nth-of-type(26) .side:nth-of-type(3):before { transition-delay: 0.7166666667s; } body .box:nth-of-type(26) .side:nth-of-type(4):before { transition-delay: 0.8833333333s; } body .box:nth-of-type(26) .side:nth-of-type(5):before { transition-delay: 1.05s; } body .box:nth-of-type(26) .side:nth-of-type(6):before { transition-delay: 1.2166666667s; } body .box:nth-of-type(27) { transition-delay: 0.45s; } body .box:nth-of-type(27) .side:nth-of-type(1):before { transition-delay: 0.3916666667s; } body .box:nth-of-type(27) .side:nth-of-type(2):before { transition-delay: 0.5583333333s; } body .box:nth-of-type(27) .side:nth-of-type(3):before { transition-delay: 0.725s; } body .box:nth-of-type(27) .side:nth-of-type(4):before { transition-delay: 0.8916666667s; } body .box:nth-of-type(27) .side:nth-of-type(5):before { transition-delay: 1.0583333333s; } body .box:nth-of-type(27) .side:nth-of-type(6):before { transition-delay: 1.225s; } body .box:nth-of-type(28) { transition-delay: 0.4666666667s; } body .box:nth-of-type(28) .side:nth-of-type(1):before { transition-delay: 0.4s; } body .box:nth-of-type(28) .side:nth-of-type(2):before { transition-delay: 0.5666666667s; } body .box:nth-of-type(28) .side:nth-of-type(3):before { transition-delay: 0.7333333333s; } body .box:nth-of-type(28) .side:nth-of-type(4):before { transition-delay: 0.9s; } body .box:nth-of-type(28) .side:nth-of-type(5):before { transition-delay: 1.0666666667s; } body .box:nth-of-type(28) .side:nth-of-type(6):before { transition-delay: 1.2333333333s; } body .box:nth-of-type(29) { transition-delay: 0.4833333333s; } body .box:nth-of-type(29) .side:nth-of-type(1):before { transition-delay: 0.4083333333s; } body .box:nth-of-type(29) .side:nth-of-type(2):before { transition-delay: 0.575s; } body .box:nth-of-type(29) .side:nth-of-type(3):before { transition-delay: 0.7416666667s; } body .box:nth-of-type(29) .side:nth-of-type(4):before { transition-delay: 0.9083333333s; } body .box:nth-of-type(29) .side:nth-of-type(5):before { transition-delay: 1.075s; } body .box:nth-of-type(29) .side:nth-of-type(6):before { transition-delay: 1.2416666667s; } body .box:nth-of-type(30) { transition-delay: 0.5s; } body .box:nth-of-type(30) .side:nth-of-type(1):before { transition-delay: 0.4166666667s; } body .box:nth-of-type(30) .side:nth-of-type(2):before { transition-delay: 0.5833333333s; } body .box:nth-of-type(30) .side:nth-of-type(3):before { transition-delay: 0.75s; } body .box:nth-of-type(30) .side:nth-of-type(4):before { transition-delay: 0.9166666667s; } body .box:nth-of-type(30) .side:nth-of-type(5):before { transition-delay: 1.0833333333s; } body .box:nth-of-type(30) .side:nth-of-type(6):before { transition-delay: 1.25s; } body .box:nth-of-type(31) { transition-delay: 0.5166666667s; } body .box:nth-of-type(31) .side:nth-of-type(1):before { transition-delay: 0.425s; } body .box:nth-of-type(31) .side:nth-of-type(2):before { transition-delay: 0.5916666667s; } body .box:nth-of-type(31) .side:nth-of-type(3):before { transition-delay: 0.7583333333s; } body .box:nth-of-type(31) .side:nth-of-type(4):before { transition-delay: 0.925s; } body .box:nth-of-type(31) .side:nth-of-type(5):before { transition-delay: 1.0916666667s; } body .box:nth-of-type(31) .side:nth-of-type(6):before { transition-delay: 1.2583333333s; } body .box:nth-of-type(32) { transition-delay: 0.5333333333s; } body .box:nth-of-type(32) .side:nth-of-type(1):before { transition-d.........完整代码请登录后点击上方下载按钮下载查看
网友评论0