Wednesday, 3 June 2020

Checkbox style css

Css : 
/*  check box css */

 .containercheckbox {
  display: block;
  position: relative;
  padding-left: 30px;
  margin-bottom: 12px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none; 
}

/* Hide the browser's default checkbox */
.containercheckbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Create a custom checkbox */
.checkmark {
  position: absolute;
  top: 7;
  left: 0;
  height: 15px;
  width: 15px;
  background-color: #04B19E;
  border-radius: 4px;
}

/* On mouse-over, add a grey background color */
.containercheckbox:hover input ~ .checkmark {
  background-color: #04B19E;
}

/* When the checkbox is checked, add a blue background */
.containercheckbox input:checked ~ .checkmark {
  background-color: #04B19E;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show the checkmark when checked */
.containercheckbox input:checked ~ .checkmark:after {
  display: block;
}

/* Style the checkmark/indicator */
.containercheckbox .checkmark:after {
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 3px 3px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}


HTML : 
<label class="containercheckbox col-sm-2 col-form-label">Vital
  <input type="checkbox" name="vital_check" value="1" class="is_checked" checked="checked">
  <span class="checkmark"></span>
</label>

No comments: