You can use parent class.
]]>Hey there! Do you happen to have a link to a Codepen (or some other demo with the code) where that is?
]]>I did some cleaning and now it’s working just fine! I don’t remember what was the previous state in order to compare them and learn about it :-\ Thank you for your help.
]]>Hm, that’s odd. The CSS should not change the state of the checkbox, but merely style it based on the state of it — in this case, when it is in a checked state. Have you tried removing one each property individually to see if one of them is the culprit? That might help isolate the issue, if it is in the CSS.
]]>If I remove this attribute, any checkbox can be checked or unchecked.
input[type=checkbox]:checked + label {
text-decoration: line-through;
opacity: 0.4;
}
I’m working on Google Chrome Version 64.0.3282.140 (Official Build) (64-bit).
]]>Also interesting: there is a 3rd state for checkboxes, radio button groups and bars. It is :indeterminate and can be set with JavaScript.
]]><input type="checkbox" > Guess what <div> Working Submenu <br>over background</div> ????????????????????????
<style>
input[type=checkbox] + div {display:none}
input[type=checkbox]:checked + div {display:inline-block;position:absolute;background-color:#ddf}
</style>
]]><input type="checkbox" > Guess what <div> Working Submenu </div>
<style>
input[type=checkbox] + div {display:none}
input[type=checkbox]:checked + div {display:inline-block}
</style>
]]><input type="checkbox" > Guess what <div> Working Submenu </div>
<style>
input[type=checkbox] + div {display:none}
input[type=checkbox]:checked + div {display:inline-block}
</style>
]]>Working Submenu
input[type=checkbox] + div {display:none} input[type=checkbox]:checked + div {display:inline-block}
]]>Sadly putting the label after the relevant field means that the field/label pair are not accessible according to the WCAG 2.0. There are a lot of examples of this field + label pattern out there but in order for the markup to make sense to all users and assistive technology the label should come first.
I await the day we can use selectors which target the preceding item
]]>