-1

.background{
  width: 200px;
  height: 100px;
  background: ;
}
input:checked ~ div{
  background: blue;
}
  <input type="checkbox" id="hamburguesa">
 <label for="hamburguesa">click here</label>

<div class="background">aasd</div>

how can i dothe first result on the second snippet? there is some way to select a father element?

i want change events using only css without js

    .background{
      width: 200px;
      height: 100px;
      background: ;
    }
    input:checked ~ div{
      background: blue;
    }
<div class="hambur">
  <input type="checkbox" id="hamburguesa">
 <label for="hamburguesa">click here</label>
</div>
<div class="background">aasd</div>
c4rlosls
  • 53
  • 8

1 Answers1

1

CSS Selector Level 4 has a selector called ":has", but it isn't compatible with any browser yet, so you'll have to use javascript/jquery for now.

:has()

This is probably the best solution you can find right now: Is there a CSS parent selector?

Gogo Dev
  • 123
  • 13