پیشنمایش زنده
کد HTML
<div class="checkbox-liquid">
<input id="liquidCheckbox" type="checkbox" />
<label for="liquidCheckbox"></label>
</div>
کد CSS
.checkbox-liquid {
position: relative;
display: inline-block;
}
.checkbox-liquid input {
display: none;
}
.checkbox-liquid label {
display: inline-block;
width: 24px;
height: 24px;
background: #333;
border-radius: 4px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.checkbox-liquid label::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 0;
background: linear-gradient(180deg, #4a90e2, #50e3c2);
transition: height 0.4s;
z-index: 0;
}
.checkbox-liquid input:checked + label::before {
height: 100%;
}
.checkbox-liquid label::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
width: 14px;
height: 14px;
background: white;
/* Using a checkmark-like shape via clip-path */
clip-path: polygon(
14% 44%,
0% 63%,
34% 100%,
50% 82%,
71% 100%,
100% 64%,
80% 44%,
100% 25%,
70% 0%,
50% 18%,
29% 0%,
0% 25%
);
transition: transform 0.4s;
z-index: 1;
}
.checkbox-liquid input:checked + label::after {
transform: translate(-50%, -50%) scale(1);
}