Re:Teddit: a free and open-source Reddit front end focused o...
by GordonS on Saturday December 05, 2020 @05:35AM
(#25313428)
That's nice! But I've been using CSS for 2 decades, how did I not know this?!
Re:Teddit: a free and open-source Reddit front end focused o...
by MatmaRex on Saturday December 05, 2020 @12:44PM
(#25316508)
It was not possible 2 decades ago; :checked selector was implemented in IE 9.
Put the two together and you can do interactive elements without JS:
``` <input id="inputId" type="checkbox" /> <label for="inputId"></label> <div class="toggle-content">Some DOM</div> ```
``` label::after{ display: block; content: '[+]'; } #input, .toggle-content { display: none; }
#input:checked + label::after { content: '[-]'; } #input:checked ~ .toggle-content { display: block; } ```
Off the top of my head, so YMMV but principal is all there.
You start getting headaches if you want animate that though (keyframes that animate a max-height from 0 to 9999999px goes some of the way but feels a bit hacky/doesn't give you much control over consistent timing.)