mercredi 26 septembre 2018

Custom checkbox, change on :hover and :checked. Doesn't work

I have problem with my custom checkbox. I would like to change color to green on :hover and yellow on checked.

I tried almost 10 different ways :/ Someone could help me? Code Pen

    <div class="form__checkbox">
      <label for="accept" class="form__checkbox-label">I have read and accept the terms of use.</label>
      <input type="checkbox" id="accept" class="form__checkbox-input">
    </div>

 &__checkbox {
z-index: 2;
position: relative;
&-label {
  cursor: pointer;
  @include inputFonts();
  margin-left: 46px;
  padding: 0.5rem;
  font-size: 1.6rem;

  &::before {
    content: "";
    display: block;
    position: absolute;
    left: 2%;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: blue;
    margin-right: 20px;
  }
  &:hover + &::before {
    background-color: red;
    height: 40px;
  }
}
&-input {
  position: absolute;
  top: -999999px;
  opacity: 0;
}

}




Aucun commentaire:

Enregistrer un commentaire