dimanche 10 novembre 2019

Cannot set background color for unchecked checkbox

I am trying to set the background color of a non-checked checkbox to white and I cannot find a way to do it. It keeps the blue color also when it's checked and also when unchecked. I've tried with:

input[type=checkbox]:not(:checked) {
    background-color: white;
}

and also:

input[type=checkbox]:after { (this one I don't think it's even valid)
    background-color: white;
}

My code for the moment is:

input[type=checkbox] {
  position: relative;
  cursor: pointer;
}
input[type=checkbox]:before {
  content: "";
  display: block;
  position: absolute;
  width: 16px;
  height: 16px;
  top: 0;
  left: 0;
  border: 1px solid #99AFC1;
  border-radius: 3px;
  background-color: #00AEEF;
  padding: 1px;
}

input[type=checkbox]:checked:after {
  content: "";
  display: block;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
  position: absolute;
  top: 2px;
  left: 6px;
}

And the html is a simple one:

<div class="container">
    <input type="checkbox" name="test">
</div>

If someone has any ideas, I will appreciate it. Thank you




Aucun commentaire:

Enregistrer un commentaire