Is is possible to toggle a class with only css?
Say I have the following:
<div class="parent">
<div class="child collapsed">
Boring Text
</div>
</div>
Is is possible, just with css, that when you click on the parent
, you can switch the collapsed
class to expanded
and vice versa?
Is is possible to toggle a class with only css?
No.
You can have state handled by using pseudo-classes such as :hover
, :active
, :checked
, and :target
but this is not the same as changing the state of class attributes the DOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With