react实现摇骰子随机数代码
代码语言:html
所属分类:其他
代码描述:react实现摇骰子随机数代码,点击开始摇,再点停止。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/babel.7.18.13.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.18.2.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.18.2.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.11.0.js"></script> <style> @import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300..700&display=swap"); @font-face { font-family: "MarioPartyHudson"; src: url("https://images.yoannbraie.fr/fonts/Mario-Party-Hudson-Font.ttf") format("truetype"); font-weight: normal; font-style: normal; } * { box-sizing: border-box; font-family: "Quicksand", sans-serif; } body { --main-color: #bfd0cd; --seconday-color: #1c1c1c; --main-gradient: linear-gradient(90deg, #35c4ff 0%, #b24eff 100%); margin: 0; padding: 0; background-color: var(--main-color); color: white; perspective: 800px; } main { min-height: 100vh; display: flex; align-items: center; justify-content: center; } ul { list-style: none; margin: 0; padding: 0; } .MarioPartyDice label { font-family: "MarioPartyHudson", sans-serif; font-size: 3em; } .MarioPartyDice { position: relative; width: 100px; height: 100px; transform-style: preserve-3d; transform-origin: 50% 50%; pointer-events: none; } .face { position: absolute; width: 100px; height: 100px; background-color: #eb433e; display: flex; justify-content: center; align-items: center; font-size: 24px; border-radius: 6px; font-family: sans-serif; } .MarioPartyDice label { --label-size: 80%; width: var(--label-size); height: var(--label-size); display: flex; justify-content: center; align-items: center; background-color: white; border-radius: 15px; color: #fef444; text-shadow: 0px 2px 5px #474747, 1px 7px 3px rgba(206, 89, 55, 0); } .face-5 > label { transform: rotateZ(180deg) rotateY(180deg); } .face-6 > label { transform: rotateY(360deg) rotateX(180deg); } .MarioPartyDiceContainer { cursor: pointer; } </style> </head> <body translate="no"> <div id="root"></div> <script type="text/babel"> function De() { function handleClick() { if (deAnimation.paused()) { deAnimation.play(); return; } deAnimation.pause(); const result = Math.floor(Math.random() * 6) + 1; let rotateX = 0; let rotateY = 0; let rotateZ = 0; let translateX = 0; let translateY = 0; switch (result) { case 2: rotateY = -90; translateX = 50; break; case 3: rotateY =.........完整代码请登录后点击上方下载按钮下载查看
网友评论0