css+js实现三维棋盘旋转动画效果代码
代码语言:html
所属分类:三维
代码描述:css+js实现三维棋盘旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; box-sizing: border-box; text-decoration: none; list-style-type: none; } body { min-height: 100vh; display: flex; justify-content: center; align-items: center; position: relative; background: #242424; } .container { width: 600px; height: 600px; border-radius: 4px; display: flex; justify-content: center; align-items: center; perspective: 10000px; perspective-origin: center; animation: perspective 8s cubic-bezier(0.4, 0, 0.1, 1) infinite; } .container .cube { width: 50px; height: 100px; position: absolute; transform-style: preserve-3d; transform: rotate3d(1, 1, 1, 0deg); } .container .cube.odd .side.bottom, .container .cube.odd .side.top { background-color: #fff; } .container .cube.odd .side.front, .container .cube.odd .side.back, .container .cube.odd .side.left, .container .cube.odd .side.right { background: #d7d7d7; background: linear-gradient(0deg, #d7d7d7 0%, #000 100%); } .container .cube.even .side.bottom, .container .cube.even .side.top { background-color: #000; } .container .cube.even .side.front, .container .cube.even .side.back, .container .cube.even .side.left, .container .cube.even .side.right { background: #d7d7d7; background: linear-gradient(0deg, #464646 0%, #000 100%); } .container .cube > .side { position: absolute; width: 100%; height: 100%; } .container .cube > .side.top { transform: rotateX(90deg) translateZ(25px); width: 50px; height: 50px; } .container .cube > .side.front { transform: translateZ(25px); height: 100px; } .container .cube > .side.back { transform: translateZ(-25px); height: 100px; } .container .cube > .side.left { transform: rotateY(90deg) translateZ(25px); height: 100px; width: 50px; } .container .cube > .side.right { transform: rotateY(-90deg) translateZ(25px); height: 100px; width: 50px; } .container .cube > .side.bottom { transform: rotateX(-90deg) translateZ(75px); width: 50px; height: 50px; } .container .chessboard { width: 400px; height: 20px; position: relative; transform-style: preserve-3d; transform: rotate3d(20, 20, 20, 120deg); animation: rotate 8s cubic-bezier(0.4, 0, 0.1, 1) infinite; } .container .chessboard > .side { position: absolute; width: 100%; height: 100%; } .container .chessboard > .side.top { transform: rotateX(90deg) tra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0