پیشنمایش زنده
کد HTML
<label class="container">
<input type="checkbox" />
<div class="checkmark"></div>
</label>
کد CSS
.container input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.container {
display: block;
position: relative;
cursor: pointer;
user-select: none;
}
.checkmark {
position: relative;
top: 0;
left: 0;
height: 32px;
width: 32px;
background-color: #b87333;
border: 2px solid #8b5a2b;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
transition: all 0.3s ease;
}
.checkmark:before {
content: "";
position: absolute;
top: 2px;
left: 2px;
right: 2px;
bottom: 2px;
background: repeating-linear-gradient(
45deg,
transparent,
transparent 2px,
rgba(0, 0, 0, 0.1) 2px,
rgba(0, 0, 0, 0.1) 4px
);
}
.container input:checked ~ .checkmark {
background-color: #ffcc66;
border-color: #ffaa00;
box-shadow:
0 0 10px #ffcc66,
0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}
.container input:checked ~ .checkmark:after {
content: "";
position: absolute;
top: 6px;
left: 6px;
right: 6px;
bottom: 6px;
background: rgba(255, 255, 255, 0.7);
box-shadow: 0 0 8px rgba(255, 255, 255, 0.5) inset;
}
.container:hover .checkmark {
background-color: #cd853f;
}
.container:hover input:checked ~ .checkmark {
background-color: #ffd700;
box-shadow:
0 0 15px #ffd700,
0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}