jquery+css实现三维摇骰子显示随机数动画效果代码
代码语言:html
所属分类:其他
代码描述:jquery+css实现三维摇骰子显示随机数动画效果代码
代码标签: jquery css 三维 摇 骰子 显示 随机数 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css"> <style> @import url("https://fonts.googleapis.com/css?family=Work+Sans:400,700,900"); body { font-family: "Work Sans", sans-serif; height: 100vh; overflow: hidden; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background: #272825; color: #fa2d7d; color: #575344; } [onclick] { outline: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .viewport { perspective: 400px; perspective-origin: 50% 50%; position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; } .cube { font-size: 0.5em; position: relative; margin: 0 auto; height: 10em; width: 10em; transform-style: preserve-3d; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); transition: transform 1s ease-out; display: inline-block; margin: 4em; } .cube > div { overflow: hidden; position: absolute; height: 10em; width: 10em; border: 0.3em solid; background: #272825; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; box-shadow: 0 0 4em rgba(0, 0, 0, 0.35) inset; border-radius: 0.5em; outline: 1px solid transparent; cursor: pointer; } .cube > div > div { font-size: 4em; font-weight: 600; width: 1em; height: 1em; position: absolute; top: 50%; left: 50%; margin-top: -0.5em; margin-left: -0.5em; transform: rotate(180deg); line-height: 1; text-align: center; color: #fa2d7d; } .cube > div:first-child { transform: rotateX(90deg) translateZ(5em); } .cube > div:nth-child(2) { transform: translateZ(5em); } .cube > div:nth-child(3) { transform: rotateY(90deg) translateZ(5em); } .cube > div:nth-child(4) { transform: rotateY(180deg) translateZ(5em); } .cube > div:nth-child(5) { transform: rotateY(-90deg) translateZ(5em); } .cube > div:nth-child(6) { transform: rotateX(-90deg) rotate(180deg) translateZ(5em); } .cube.index-1 { transform: rotateX(280deg) rotateY(185deg) rotateZ(0deg); } .cube.index-2 { transform: rotateX(10deg) rotateY(5deg) rotateZ(180deg); } .cube.index-3 { transform: rotateX(100deg) rotateY(95deg) rotateZ(90deg); } .cube.index-4 { transform: rotateX(190deg) rotateY(5deg) rotateZ(0deg); } .cube.index-5 { transform: rotateX(10deg) rotateY(275deg) rotateZ(180deg); } .cube.index-6 { transform: rotateX(280deg) rotateY(185deg) rotateZ(180deg); } .cube.bis.index-1 { transform: rotateX(610deg) rotateY(545deg) rotateZ(365deg); } .cube.bis.index-2 { transform: rotateX(340deg) rotateY(365deg) rotateZ(545deg); } .cube.bis.index-3 { transform: rotateX(430deg) rotateY(455deg) rotateZ(455deg); } .cube.bis.index-4 { transform: rotateX(520deg) rotateY(365deg) rotateZ(365deg); } .cube.bis.index-5 { transform: rotateX(340deg) rotateY(635deg) rotateZ(545deg); } .cube.bis.index-6 { transform: rotateX(610deg) rotateY(545deg) rotateZ(545deg); } .buttons { display: block; text-align: center; position: absolute; bottom: 10vh; left: 0; right: 0; } .buttons button { display: inline-block; border: none; border-radius: 0.2em; font-size: 1.5em; outline: none; background: #fa2d7d; color: #FFF; padding: 0.5em 1em; cursor: pointer; } .buttons button:active { transform: scale(0.9); } .buttons button + button { display: none; } </style> </head> <body> <!-- partial:index.partial.html --> <div class="viewport"> <div class="cube bis index-2"> <div class="side"> <div>1</div> </div> <div class="side"> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0