پیش‌نمایش زنده
کد HTML
<div class="checkbox-container">
  <input type="checkbox" id="animated-checkbox" class="checkbox-input" />
  <label for="animated-checkbox" class="checkbox">
    <span class="line line1"></span>
    <span class="line line2"></span>
  </label>
</div>
کد CSS
/* Checkbox Container */
.checkbox-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Hidden Checkbox Input */
.checkbox-input {
  display: none;
}

/* Checkbox Label */
.checkbox {
  position: relative;
  width: 50px;
  height: 50px;
  background: #333;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s ease-in-out;
  box-shadow:
    inset -4px -4px 8px #000000,
    inset 4px 4px 8px #444444;
}

/* X Mark Lines */
.line {
  position: absolute;
  width: 30px;
  height: 4px;
  background: #888;
  border-radius: 2px;
  transition: all 0.3s ease-in-out;
}

/* X Mark Line 1 */
.line1 {
  transform: rotate(45deg);
}

/* X Mark Line 2 */
.line2 {
  transform: rotate(-45deg);
}

/* Checked State */
.checkbox-input:checked + .checkbox {
  background: #444;
}

.checkbox-input:checked + .checkbox .line1 {
  transform: rotate(50deg) translateX(-3px) translateY(8px) scaleX(0.6);
  background: #4caf50;
}

.checkbox-input:checked + .checkbox .line2 {
  transform: rotate(-50deg) translateX(6px) translateY(3px);
  background: #4caf50;
}
نوع: checkbox
تاریخ ایجاد: 2026/06/05
آخرین بروزرسانی: 2026/06/05