پیشنمایش زنده
کد HTML
<div class="clock-input">
<input type="radio" id="v1" name="radio" checked="" />
<input type="radio" id="v2" name="radio" />
<input type="radio" id="v3" name="radio" />
<input type="radio" id="v4" name="radio" />
<input type="radio" id="v5" name="radio" />
<input type="radio" id="v6" name="radio" />
<label for="v1" id="l1"></label>
<label for="v2" id="l2"></label>
<label for="v3" id="l3"></label>
<label for="v4" id="l4"></label>
<label for="v5" id="l5"></label>
<label for="v6" id="l6"></label>
<div class="dial"></div>
<div class="notches">
<div class="notch" style="--n:1"></div>
<div class="notch" style="--n:2"></div>
<div class="notch" style="--n:3"></div>
<div class="notch" style="--n:4"></div>
<div class="notch" style="--n:5"></div>
<div class="notch" style="--n:6"></div>
</div>
</div>
کد CSS
.clock-input {
display: flex;
position: relative;
width: 60px;
height: 60px;
--a: #0004, #fff4;
--b: var(--a), var(--a), var(--a);
--c: var(--b), var(--b), var(--b);
background: conic-gradient(
from -2deg,
#efefff88,
#00000088,
#efefff88,
#00000088,
#efefff88
),
radial-gradient(var(--c), var(--c)),
radial-gradient(circle at 12% 12%, #efefff, #9999a4);
background-size: calc(100% + 8px) calc(100% + 8px);
background-position: -4px -4px;
border: 4px solid #0005;
border-radius: 50%;
}
.clock-input input {
display: none;
pointer-events: none;
}
.dial {
position: absolute;
width: 26px;
height: 4px;
border-radius: 99px;
background-color: #000b;
top: calc(50% - 2px);
left: calc(50% - 2px);
transform-origin: 2px 50%;
pointer-events: none;
transition: 0.15s;
animation: owo 0.15s;
}
@keyframes owo {
0% {
transform: rotate(-60deg);
}
to {
transform: rotate(0deg);
}
}
.clock-input label {
position: absolute;
width: 48px;
height: 48px;
cursor: pointer;
}
#v1:checked ~ #l2 {
z-index: 2;
}
#v1:checked ~ .dial {
transform: rotate(0deg);
}
#v2:checked ~ #l3 {
z-index: 2;
}
#v2:checked ~ .dial {
transform: rotate(60deg);
animation: none;
}
#v3:checked ~ #l4 {
z-index: 2;
}
#v3:checked ~ .dial {
transform: rotate(120deg);
animation: none;
}
#v4:checked ~ #l5 {
z-index: 2;
}
#v4:checked ~ .dial {
transform: rotate(180deg);
animation: none;
}
#v5:checked ~ #l6 {
z-index: 2;
}
#v5:checked ~ .dial {
transform: rotate(240deg);
animation: none;
}
#v6:checked ~ #l1 {
z-index: 2;
}
#v6:checked ~ .dial {
transform: rotate(300deg);
animation: none;
}
.notch {
position: absolute;
top: 50%;
left: 50%;
width: 8px;
height: 1px;
background-color: #fffc;
transform: translate(-50%) rotate(calc((var(--n) - 1) * 60deg))
translateX(38px);
counter-reset: section;
}
.notch::before {
content: counter(section);
position: absolute;
counter-set: section var(--n);
color: #fffc;
transform: translate(12px, -50%) rotate(calc((var(--n) - 1) * -60deg));
font-size: 12px;
}