News for hackers. Stuff that matters.
Re:HTML and CSS techniques to reduce your JavaScript by SimeVidas on Thursday June 03, 2021 @11:45PM (#27390334)
> checkbox/radio inputs can be used to toggle state with `:checked ~ .foo` selectors

What kind of state do you mean? Could you give an example?

Re:HTML and CSS techniques to reduce your JavaScript by joeframbach on Thursday June 03, 2021 @11:57PM (#27390392)
An accordion widget is simply a series of radio button followed by div. You can see this in action at amazon.com in a product page with multiple purchase options, the buy button will have a radio with multiple options, it's just a radio button. An accordion that allows multiple open panes is a series of checkbox followed by div. More advanced, you can create a flashcard app by allotting two checkboxes per card. I used this technique around 3 years ago when I was studying kanji: http://sokogakuen.framba.ch
Re:HTML and CSS techniques to reduce your JavaScript by charrondev on Friday June 04, 2021 @12:02AM (#27390410)
The pattern is:

<label> <input class”real-check” type=checkbox /> <span class”fake-check”/> <strong>this is the text label</strong> </label>

- visually hide the checkbox - use a selector like “.real-check:checked + .fake-check and draw whatever you want in the fake check. - the fake check and the text label are both inside the label element. Interacting with them will toggle the check box.

Re:HTML and CSS techniques to reduce your JavaScript by inopinatus on Friday June 04, 2021 @12:25AM (#27390534)
Here's a simple example, toggles for checkbox inputs. https://play.tailwindcss.com/BvQpg9QWEe
Re:HTML and CSS techniques to reduce your JavaScript by meagher on Friday June 04, 2021 @12:44AM (#27390659)