css实现三维立体数字骰子跟随鼠标旋转动画效果代码
代码语言:html
所属分类:三维
代码描述:css实现三维立体数字骰子跟随鼠标旋转动画效果代码
代码标签: css 三维 立体 数字 骰子 跟随 鼠标 旋转 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=Fjalla+One&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
min-height: 100vh;
background-image: radial-gradient(#4d4d4d, #0d0d0d);
overflow: hidden;
perspective: 1000px;
font-family: "Fjalla One", sans-serif;
}
body .scene, body .scene * {
transform-style: preserve-3d;
}
body .scene {
position: relative;
width: 70vw;
height: 70vw;
margin-top: -60%;
transform: rotateX(-40deg) rotateY(0deg) scale3d(1, 1, 1);
animation: rot 30s ease-in-out 2s infinite alternate;
}
@keyframes rot {
to {
transform: rotateX(0deg) rotateY(360deg) scale3d(1, 1, 1);
}
}
body .scene::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: -100;
box-shadow: inset 0 0 7vw #000;
background-color: #1a1a1a;
background-image: repeating-linear-gradient(#0000 0% 50%, #0000 50% 100%), repeating-radial-gradient(circle, #0000 0% 50%, #2e2e2e 50% 100%);
background-size: 100%, 2vw 2vw, 2vw 2vw;
transform: rotateX(90deg) translateZ(calc(70vw / -2)) scale(1);
border-radius: 50%;
}
body .scene .dices {
position: relative;
width: 100%;
height: 100%;
bottom: 0;
transform: translateX(12vw);
}
body .scene .cube, body .scene .cube * {
position: absolute;
bottom: 0;
}
body .scene .cube .container {
display: grid;
place-items: center;
font-size: 5vw;
counter-reset: dice;
}
body .scene .cube .container div {
counter-increment: dice;
background-image: radial-gradient(circle, #0005 50%, #fff1 50% 55%, #0000 60% 100%);
color: gray;
text-shadow: -1px 1px 3px rgba(0, 0, 0, 0.5), 1px -1px 0 rgba(255, 255, 255, 0.9);
}
body .scene .cube .container div:nth-child(1)::after {
content: counter(dice);
}
body .scene .cube .container div:nth-child(2)::after {
content: counter(dice);
}
body .scene .cube .container div:nth-child(3)::after {
content: counter(dice);
}
body .scene .cube .container div:nth-child(4)::after {
content: counter(dice);
}
body .scene .cube .container div:nth-child(5)::after {
content: counter(dice);
}
body .scene .cube .container div:nth-child(6)::after {
content: counter(dice);
}
body .scene #dice-1 {
width: 10vw;
height: 10vw;
transform: translate3d(7vw, -10vw, 0);.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0