0

This is my class -

.swatch input:checked + label {
 background-color: #fff;
} 




 .swatch {
    Change something here when above class is active.
 }

Is there any way to do this? I am using liquid templating if that could be of assistance.

1

1 Answer 1

1

No.

It is possible for one ruleset to affect another using CSS variables…

body {
  --example: yellow;
}

input:checked+.swatch {
  --example: brown;
}

.swatch {
  background: var(--example);
}
<input type="checkbox">

<div class="swatch">
  Hello, world
</div>

… but that would only allow the variable to be set on the input, it's descendant (if inputs could have such things) or a later sibling.

There is no parent selector.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.