Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toggle class with css not jquery

Tags:

css

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?

like image 785
KingKongFrog Avatar asked Aug 14 '13 17:08

KingKongFrog


1 Answers

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.

like image 87
zzzzBov Avatar answered Nov 15 '22 08:11

zzzzBov