![]() |
|
(Pure CSS) Expand/collapse objects WITHOUT JAVASCRIPT - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141) +---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50) +---- Thread: (Pure CSS) Expand/collapse objects WITHOUT JAVASCRIPT (/showthread.php?tid=5747279) |
(Pure CSS) Expand/collapse objects WITHOUT JAVASCRIPT - Тоху - Nov 3, 2017 I wrote this for some project I'm working on and recommended it be used for the menu here on the top left of the form for non-js compatibility, so I figured I'd post it here. Here's all the CSS you need: Spoiler (Click to View) And some html: Spoiler (Click to View) You may be able to substitute input[type=checkbox]:checked for #collapseobj:checked to use with multiple checkboxes, but I haven't tested this (though it is working here https://codepen.io/tomasz86/pen/wuzcK) What's going on here? Well, we're using the checkbox hack. When the checkbox (which we give content to with css) is clicked, it will change the css of the collapseobj class, back and forth. Now, I haven't positioned the button in that short little html snippet so you'll have to do it yourself. But that's how it's done. I've found using opacity fading with the animation makes it appear a little smoother. Hope you all can employ this cool css trick and get rid of your JS! 🎉 RE: (Pure CSS) Expand/collapse objects WITHOUT JAVASCRIPT - Rushax - Nov 3, 2017 Great little nugget thanks for the share! Barely any CSS + no JS too, what a bonus. RE: (Pure CSS) Expand/collapse objects WITHOUT JAVASCRIPT - Ganja - Nov 4, 2017 yeah this is a nice trick, I often use this to make dropdown/hamburger-menus without JS |