正方体飞舞动态背景效果
代码语言:html
所属分类:背景
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> Blue Background</title> <style> /* basic style */ html, body { position: relative; overflow: hidden; } body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: radial-gradient(ellipse at left top, #72c7fe, #fafdff); } div { transform-style: preserve-3d; } .container { width: 100%; height: 100%; perspective: 1000px; } /* cube style */ .cube_wrap:nth-of-type(1) { position: absolute; top: 57%; left: calc(50% + 10px); width: 10vw; height: 10vw; animation: cube 32s linear -28s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(1) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 35s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(1) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(87deg); } .cube_wrap:nth-of-type(1) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(1) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(1) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(1) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(1) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(1) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(1) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(2) { position: absolute; top: 38%; left: calc(50% + 20px); width: 10vw; height: 10vw; animation: cube 34s linear -26s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(2) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 39s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(2) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(22deg); } .cube_wrap:nth-of-type(2) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(2) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(2) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(2) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(2) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(2) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(2) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(3) { position: absolute; top: 37%; left: calc(50% + 30px); width: 10vw; height: 10vw; animation: cube 36s linear -24s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(3) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 36s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(3) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(125deg); } .cube_wrap:nth-of-type(3) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(3) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(3) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(3) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(3) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(3) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(3) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(4) { position: absolute; top: 32%; left: calc(50% + 40px); width: 10vw; height: 10vw; animation: cube 38s linear -22s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(4) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 31s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(4) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(169deg); } .cube_wrap:nth-of-type(4) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(4) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(4) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(4) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(4) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(4) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(4) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(5) { position: absolute; top: 23%; left: calc(50% + 50px); width: 10vw; height: 10vw; animation: cube 40s linear -20s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(5) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 26s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(5) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(150deg); } .cube_wrap:nth-of-type(5) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(5) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(5) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(5) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(5) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(5) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(5) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(6) { position: absolute; top: 63%; left: calc(50% + 60px); width: 10vw; height: 10vw; animation: cube 42s linear -18s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(6) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 38s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(6) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(103deg); } .cube_wrap:nth-of-type(6) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(6) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(6) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(6) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(6) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(6) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(6) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(7) { position: absolute; top: 52%; left: calc(50% + 70px); width: 10vw; height: 10vw; animation: cube 44s linear -16s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(7) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 29s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(7) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(151deg); } .cube_wrap:nth-of-type(7) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(7) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(7) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(7) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(7) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(7) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(7) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(8) { position: absolute; top: 47%; left: calc(50% + 80px); width: 10vw; height: 10vw; animation: cube 46s linear -14s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(8) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 40s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(8) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(83deg); } .cube_wrap:nth-of-type(8) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(8) .front { transform: translateZ(5vw); } .cube_wrap:nth-of-type(8) .back { transform: rotateY(180deg) translateZ(5vw); } .cube_wrap:nth-of-type(8) .left { transform: rotateY(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(8) .right { transform: rotateY(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(8) .top { transform: rotateX(90deg) translateZ(5vw); } .cube_wrap:nth-of-type(8) .bottom { transform: rotateX(-90deg) translateZ(5vw); } .cube_wrap:nth-of-type(9) { position: absolute; top: 53%; left: calc(50% + 90px); width: 6vw; height: 6vw; animation: cube 48s linear -12s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(9) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 23s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(9) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(142deg); } .cube_wrap:nth-of-type(9) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(9) .front { transform: translateZ(3vw); } .cube_wrap:nth-of-type(9) .back { transform: rotateY(180deg) translateZ(3vw); } .cube_wrap:nth-of-type(9) .left { transform: rotateY(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(9) .right { transform: rotateY(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(9) .top { transform: rotateX(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(9) .bottom { transform: rotateX(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(10) { position: absolute; top: 35%; left: calc(50% + 100px); width: 6vw; height: 6vw; animation: cube 50s linear -10s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(10) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 37s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(10) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(145deg); } .cube_wrap:nth-of-type(10) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(10) .front { transform: translateZ(3vw); } .cube_wrap:nth-of-type(10) .back { transform: rotateY(180deg) translateZ(3vw); } .cube_wrap:nth-of-type(10) .left { transform: rotateY(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(10) .right { transform: rotateY(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(10) .top { transform: rotateX(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(10) .bottom { transform: rotateX(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(11) { position: absolute; top: 36%; left: calc(50% + 110px); width: 6vw; height: 6vw; animation: cube 52s linear -8s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(11) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 25s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(11) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(22deg); } .cube_wrap:nth-of-type(11) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(11) .front { transform: translateZ(3vw); } .cube_wrap:nth-of-type(11) .back { transform: rotateY(180deg) translateZ(3vw); } .cube_wrap:nth-of-type(11) .left { transform: rotateY(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(11) .right { transform: rotateY(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(11) .top { transform: rotateX(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(11) .bottom { transform: rotateX(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(12) { position: absolute; top: 42%; left: calc(50% + 120px); width: 6vw; height: 6vw; animation: cube 54s linear -6s infinite; opacity: 0.7; z-index: 99; } @keyframes cube { 0% { transform: translateX(-150vw); } 100% { transform: translateX(150vw); } } .cube_wrap:nth-of-type(12) .cube { position: absolute; width: 100%; height: 100%; animation: rotation 25s linear infinite; } @keyframes rotation { 100% { transform: rotateX(360deg) rotateY(360deg); } } .cube_wrap:nth-of-type(12) .rotation { position: absolute; width: 100%; height: 100%; transform: rotate(41deg); } .cube_wrap:nth-of-type(12) .wall { position: absolute; width: 100%; height: 100%; border: solid 3px #fff; } .cube_wrap:nth-of-type(12) .front { transform: translateZ(3vw); } .cube_wrap:nth-of-type(12) .back { transform: rotateY(180deg) translateZ(3vw); } .cube_wrap:nth-of-type(12) .left { transform: rotateY(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(12) .right { transform: rotateY(-90deg) translateZ(3vw); } .cube_wrap:nth-of-type(12) .top { transform: rotateX(90deg) translateZ(3vw); } .cube_wrap:nth-of-type(12) .bottom { transform: rotateX(-90deg) translateZ(3vw); } /* square style */ .square:nth-of-type(1) { position: absolute; top: calc(20% + 158px); left: 91%; opacity: 0.3; } .square:nth-of-type(2) { position: absolute; top: calc(20% + 48px);.........完整代码请登录后点击上方下载按钮下载查看
网友评论0