پیشنمایش زنده
کد HTML
<div class="checkbox-container">
<label class="checkbox-label">
<input class="checkbox-input" type="checkbox" />
<span class="checkbox-custom"></span>
</label>
</div>
کد CSS
/* Container for checkbox */
.checkbox-container {
display: flex;
align-items: center;
gap: 10px;
}
.checkbox-label {
display: flex;
align-items: center;
cursor: pointer;
font-family: "Arial", sans-serif;
font-size: 16px;
color: #522f2f;
}
/* Hide native checkbox */
.checkbox-input {
display: none;
}
/* Custom checkbox (Ping Pong Ball design) */
.checkbox-custom {
width: 40px;
height: 40px;
background: radial-gradient(circle at 30% 30%, white 15%, #f0f0f0 85%);
border-radius: 50%;
border: 2px solid #ccc;
position: relative;
box-shadow:
0 6px 10px rgba(0, 0, 0, 0.15),
inset -3px -3px 5px rgba(255, 255, 255, 0.7);
transition: all 0.3s ease;
transform-style: preserve-3d;
}
/* Hover effect to make the ball pop */
.checkbox-label:hover .checkbox-custom {
transform: scale(1.1);
box-shadow:
0 10px 16px rgba(0, 0, 0, 0.25),
inset -3px -3px 7px rgba(255, 255, 255, 0.8);
transition:
transform 0.2s,
box-shadow 0.3s;
}
/* Checked state (apply a more obvious 3D look) */
.checkbox-input:checked + .checkbox-custom {
background: radial-gradient(circle at 30% 30%, #f0f0f0 20%, #50c7e0 85%);
border-color: #0ba4eb;
animation: bounce 0.4s ease forwards;
box-shadow:
0 8px 14px rgba(0, 0, 0, 0.3),
inset -5px -5px 8px rgba(255, 255, 255, 0.8);
}
/* Checkmark (appears like a logo on the ball) */
.checkbox-input:checked + .checkbox-custom::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
background: radial-gradient(circle at 30% 30%, white 30%, #50c7e0 90%);
border-radius: 50%;
top: 10px;
left: 10px;
box-shadow: 0 0 8px rgba(107, 189, 248, 0.966);
transform: scale(0);
transition: transform 0.3s ease;
}
.checkbox-input:checked + .checkbox-custom::after {
transform: scale(1);
}
/* Reflection effect for added realism */
.checkbox-custom::before {
content: "";
position: absolute;
width: 15px;
height: 15px;
background: radial-gradient(
circle,
rgba(255, 255, 255, 0.7),
rgba(255, 255, 255, 0)
);
border-radius: 50%;
top: 5px;
left: 8px;
opacity: 0.8;
pointer-events: none;
}
/* Ping pong bounce animation */
@keyframes bounce {
0% {
transform: translateY(0) scale(1);
}
30% {
transform: translateY(-15px) scale(1.1);
}
60% {
transform: translateY(5px) scale(0.9);
}
100% {
transform: translateY(0) scale(1);
}
}