Author: | armennersisyan |
---|---|
Views Total: | 165 views |
Official Page: | Go to website |
Last Update: | October 19, 2023 |
License: | MIT |
Preview:

Description:
ExpandifyCSS is an open-source project that helps create expandable and collapsible sections using CSS grid. JavaScript is only used to toggle the expanded state of the sections.
How to use it:
1. Download and import the ‘expandify.css’ stylesheet.
<link rel="stylesheet" href="expandify.css" />
2. Create a expandable and collapsible section.
<div class="expandableSection"> <div class="expandableSection-inner"> <div class="contentWrapper"> ... </div> </div> </div>
3. Create a button to toggle the section.
<button id="btn">Toggle</button>
4. Toggle the ‘expanded’ class on the element with the class ‘expandableSection’.
const toggleExpandableSection = () => { document.querySelector('.expandableSection').classList.toggle('expanded'); };
5. Attach the toggle function to the button with the ID ‘btn’.
document.getElementById('btn').addEventListener('click', toggleExpandableSection);