0

What's the CSS to make a label of a checked checkbox have a certain style?

This is basically what I want, except I want the label to have the background: blue, not the checkbox.

.results .auto-share-options li label input[type='checkbox']:checked {
    background: blue;
}
Brenden
  • 8,264
  • 14
  • 48
  • 78

2 Answers2

0

There's no way of doing this in CSS. Exhaustive answers and solutions available here: Complex CSS selector for parent of active child

Community
  • 1
  • 1
stealthyninja
  • 10,343
  • 11
  • 51
  • 59
0

You can't ascend with CSS selectors at this current time and checkbox input elements are empty elements, so you can't look for a descendent label element either.

You would need to use JavaScript to achieve this.

alex
  • 479,566
  • 201
  • 878
  • 984