-
Notifications
You must be signed in to change notification settings - Fork 756
Closed
Description
Similar to the focus-within (https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within) pseudo class, can we have a checked-within pseudo class?
Basically would allow a parent element of a checked checkbox or radio to be targeted. Sample usage:
HTML:
<div class="option">
<div class="title">
<input type="radio" id="basic" name="package" value="basic">
<label for="basic">Basic</label>
<div>
<div class="content">
<!-- some content -->
</div>
</div>
CSS:
.option {
background-color: white;
}
.option:checked-within {
background-color: green;
}
Currently we have to use JS to detect a change event on the radio button in order to apply a class on a parent element (or conditionally apply a class on the server side for rendered pages).
Zhang-Junzhi, eirikbacker, firien, dtruffaut, long-lazuli and 52 moreseeratawan01 and jsakas