console
const getPrize = () => Math.ceil(Math.random() * 3600)
const spinBtn = document.querySelector('.spin-wheel .spin')
const spinWheel = document.querySelector('.spin-wheel .wheel')
let prizeVal = getPrize()
spinBtn.onclick = () => {
spinWheel.style.transform = `rotate(${prizeVal}deg)`
prizeVal += getPrize()
}
<div class="spin-wheel">
<div class="btn spin">click</div>
<div class="container wheel">
<div class="piece" style="--i: 1;"><span>100</span></div>
<div class="piece" style="--i: 2;"><span>1</span></div>
<div class="piece" style="--i: 3;"><span>50</span></div>
<div class="piece" style="--i: 4;"><span>0</span></div>
<div class="piece" style="--i: 5;"><span>2</span></div>
<div class="piece" style="--i: 6;"><span>10</span></div>
<div class="piece" style="--i: 7;"><span>5</span></div>
<div class="piece" style="--i: 8;"><span>20</span></div>
</div>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #333;
}
.spin-wheel {
--btn-color: #ff340f;
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 400px;
height: 400px;
}
.spin-wheel .btn {
position: absolute;
top: 50%;
left: 50%;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
width: 60px;
height: 60px;
background-color: var(--btn-color);
border: 4px solid rgba(0, 0, 0, .75);
border-radius: 50%;
font-size: 14px;
font-weight: 600;
text-transform: uppercase;
color: #fff;
cursor: pointer;
user-select: none;
transform: translate(-50%, -50%);
&::before {
content: '';
position: absolute;
top: -28px;
width: 20px;
height: 30px;
background-color: var(--btn-color);
clip-path: polygon(50% 0%, 15% 100%, 85% 100%);
}
}
.spin-wheel .wheel {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #333;
border-radius: 50%;
box-shadow: 0 0 0 5px #333, 0 0 0 15px #fff, 0 0 0 18px #111;
overflow: hidden;
font-size: 14px;
transition: transform 5s ease-in-out;
}
.spin-wheel .wheel .piece {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 50%;
height: 50%;
background-color: #fff;
user-select: none;
transform-origin: bottom right;
transform: rotate(calc(45deg * var(--i)));
clip-path: polygon(0 0, 57% 0, 100% 100%, 0 57%);
}
.spin-wheel .wheel .piece span {
position: relative;
transform: rotate(45deg);
font-size: 24px;
font-weight: 700;
color: #333;
text-shadow: 3px 5px 2px rgba(0, 0, 0, .15);
}
.spin-wheel .wheel .piece span::before {
content: '¥';
margin-right: 4px;
font-size: 18px;
}