Question

I am trying to use "check box" to change color of element.

HTML:

<label for="toggle-1">I'm a toggle</label>
<input type="checkbox" id="toggle-1">
<div class="reklama">I'm controlled by toggle. No JavaScript!</div>

CSS:

.reklama {
  color:Red;
}

input#toggle-1: checked ~ .reklama{
  color:green;  
}

U can find my demo here.

Was it helpful?

Solution

You can't have any spaces before the ":checked", so that it is directly connected to your id. This will work in your CSS

input#toggle-1:checked ~ .reklama{
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top