mercredi 27 mai 2020

change style of other labels when checkbox is checked

I have an issue with the checkbox checked. I am trying to find a solution that is when my current checkbox is checked to change the opacity others checkbox. is that possible with CSS? I made it with CSS input and label. Here is my code.

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

li {
  margin-bottom: 10px;
  display: block;
}

.styled-checkbox {
  position: absolute;
  opacity: 0;
}
.styled-checkbox:checked + label {
  opacity: 1;
}
.styled-checkbox:checked + label label {
  opacity: 0.5;
}
.styled-checkbox + label {
  position: relative;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 0.875rem;
}
.styled-checkbox + label:before {
  content: '';
  margin-right: 10px;
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: text-top;
  border: 1px solid #000;
}
.styled-checkbox:checked + label:after {
  content: '';
  position: absolute;
  left: 1px;
  top: 7px;
  background: white;
  width: 2px;
  height: 2px;
  box-shadow: 2px 0 0 #000, 4px 0 0 #000, 4px -2px 0 #000, 4px -4px 0 #000, 4px -6px 0 #000, 4px -8px 0 #000;
  transform: rotate(45deg);
  transition: all 0.3s ease-out;
}
<ul>
  <li>
    <input type="checkbox" class="styled-checkbox" id="styled-checkbox-1" />
    <label for="styled-checkbox-1">Test one</label>
  </li>
  <li>
    <input type="checkbox" class="styled-checkbox" id="styled-checkbox-2" />
    <label for="styled-checkbox-2">Test Two</label>
  </li>
  <li>
    <input type="checkbox" class="styled-checkbox" id="styled-checkbox-3" />
    <label for="styled-checkbox-3">Test Three</label>
  </li>
  <li>
    <input type="checkbox" class="styled-checkbox" id="styled-checkbox-4" />
    <label for="styled-checkbox-4">Test Four</label>
  </li>
</ul>

`

desire goal is something like that

enter image description here

I hope you guys understand the problem. Thanks in advance




Aucun commentaire:

Enregistrer un commentaire