div+css实现菱形十二面体到立方体八面体的过渡变形动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现菱形十二面体到立方体八面体的过渡变形动画效果代码
代码标签: div css 菱形 十二面体 立方体 八面体 过渡 变形 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { height: 100%; } body { overflow: hidden; margin: 0; perspective: 32em; perspective-origin: calc(50% - 2em) calc(50% - 2em); background: linear-gradient(#000000, #696969); color: lemonchiffon; } .polyhedron, .polyhedron *, .polyhedron :before { box-sizing: border-box; position: absolute; top: 50%; left: 50%; transform-style: preserve-3d; } .polyhedron { animation: rot 17.39s linear infinite; } @keyframes rot { to { transform: rotateY(360deg); } } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(1) { transform: rotateX(90deg) rotateX(-45deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(2) { transform: rotateX(90deg) rotateX(45deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(3) { transform: rotateX(90deg) rotateX(135deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(4) { transform: rotateX(90deg) rotateX(225deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(5) { transform: rotateY(90deg) rotateX(315deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(6) { transform: rotateY(90deg) rotateX(405deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(7) { transform: rotateY(90deg) rotateX(495deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(8) { transform: rotateY(90deg) rotateX(585deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(9) { transform: rotateZ(90deg) rotateX(675deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(10) { transform: rotateZ(90deg) rotateX(765deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(11) { transform: rotateZ(90deg) rotateX(855deg) translateZ(6.53197em); } .polyhedron--rhombic-dodecahedron .polyhedron__face:nth-child(12) { transform: rotateZ(90deg) rotateX(945deg) translateZ(6.53197em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(1) { transform: rotateY(0deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(2) { transform: rotateY(90deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(3) { transform: rotateY(180deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(4) { transform: rotateY(270deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(5) { transform: rotateX(90deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(6) { transform: rotateX(-90deg) translateZ(9.2376em) rotate(45deg); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(7) { transform: rotateY(-45deg) rotate(180deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(8) { transform: rotateY(45deg) rotate(180deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(9) { transform: rotateY(135deg) rotate(180deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(10) { transform: rotateY(225deg) rotate(180deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(11) { transform: rotateY(45deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(12) { transform: rotateY(-45deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(13) { transform: rotateY(-135deg) rotateX(-35.24786deg) translateZ(8em); } .polyhedron--cuboctahedron .polyhedron__face:nth-child(14) { transform: rotateY(-225deg) rotateX(-35.24786deg) translateZ(8em); } .stretchers .polyhedron__face:nth-child(1) { transform: rotateY(0deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(2) { transform: rotateY(0deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(3) { transform: rotateY(0deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(4) { transform: rotateY(0deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(5) { transform: rotateY(90deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(6) { transform: rotateY(90deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(7) { transform: rotateY(90deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(8) { transform: rotateY(90deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(9) { transform: rotateY(180deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(10) { transform: rotateY(180deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(11) { transform: rotateY(180deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(12) { transform: rotateY(180deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(13) { transform: rotateY(270deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(14) { transform: rotateY(270deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(15) { transform: rotateY(270deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(16) { transform: rotateY(270deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(17) { transform: rotateX(90deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(18) { transform: rotateX(90deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(19) { transform: rotateX(90deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(20) { transform: rotateX(90deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(21) { transform: rotateX(-90deg) translateZ(4.6188em) rotate(-45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(22) { transform: rotateX(-90deg) translateZ(4.6188em) rotate(45deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(23) { transform: rotateX(-90deg) translateZ(4.6188em) rotate(135deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .stretchers .polyhedron__face:nth-child(24) { transform: rotateX(-90deg) translateZ(4.6188em) rotate(225deg) translateY(6.53197em) rotateX(-35.24786deg) translateY(-4em); } .transformer { backface-visivility: hidden; animation: ani 16s linear infinite alternate; } .polyhedron--rhombic-dodecahedron .transformer { animation-name: ani-rh; } .polyhedron--cuboctahedron .transformer.transformer--square { animation-name: ani-sq; } .polyhedron--cuboctahedron .transformer.transformer--triangle { animation-name: ani-tri; } .stretchers .transformer { animation-name: ani-rect; } @keyframes ani-rh { 0%, 12.5% { transform: translateZ(0) scale(1); } 37.5%, 62.5% { transform: translateZ(8em) scale(1); } 87.5%, 100% { transform: translateZ(1.46803em) scale(0.001); } } @keyframes ani-sq { 0%, 12.5% { transform: translateZ(0) scale(0); } 37.5%, 62.5% { transform: translateZ(5.65685em) scale(1); } 87.5%, 100% { transform: translateZ(-3.58075em) scale(1); } } @keyframes ani-tri { 0%, 12.5% { transform: translateZ(0) scale(0); } 37.5%, 62.5% { transform: translateZ(6.53197em) scale(1); } 87.5%, 100% { transform: translateZ(-1.46803em) scale(1); } } @keyframes ani-rect { 0%, 12.5% { transform: translateZ(0) scale(0, 1); } 37.5%, 62.5% { transform: translateZ(6.9282em) scale(1); opacity: 1; } 65% { opacity: 0; } 87.5%, 100% { transform: translateZ(-0.61427em) scale(1, 0); opacity: 0; } } .polygon, .polygon:before { margin: -4em; border: solid .125em; width: 8em; height: 8em; } .polygon { overflow: hidden; } .polygon:before { content: ''; } .polygon--rhombus { transform: rotate(35.24786deg) skewY(19.50429deg) scaleX(0.94262); } .polygon--rhombus:before { background: rgba(189, 21, 80, 0.41); } .polygon--square:before { background: rgba(233, 127, 2, 0.41); } .polygon--triangle { border-right-color: transparent; border-bottom-color: transparent; transform: translateY(2.3094em) rotate(30deg) skewY(30deg) scaleX(0.86603); } .polygon--triangle:before { transform: scaleX(1.1547) skewY(-30deg) rotate(-30deg) translateY(-50%); background: rgba(248, 202, 0, 0.41); } .polygon--rect:before { background: rgba(138, 155, 15, 0.41); } </style> </head> <body> <div class='polyhedron polyhedron--rhombic-dodecahedron-expansion-cuboctahedron'> <div class='polyhedron__comp polyhedron--rhombic-dodecahedron'> <div class='polyhedron__face'> <div class='transformer shifter-scaler'> <div class='polygon polygon--rhombus'></div> </div> </div> <div class='polyhedron__face'> <div class='transformer shifter-scaler'> <div class='polygon polygon--rhombus'></div> </div>.........完整代码请登录后点击上方下载按钮下载查看
网友评论0