This is a solution to the FAQ Accordion Card Challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building real-world projects.
Users should be able to:
- View the optimal layout depending on their device's screen size.
- See hover states for all interactive elements.
- Expand/collapse answers when clicking a question.
Desktop Design
Mobile Design
- Solution URL: Frontend Mentor Solution
- Live Site URL: Live Demo
Since this project uses LESS for styling, you'll need to compile it into standard CSS.
- Install Node.js if you haven't already.
- Open the terminal and install LESS globally:
npm install -g less
- Navigate to the project directory and compile the LESS file:
lessc style.less style.css
- Open
index.html
in your browser.
- Install the Live LESS Compiler extension from the VS Code marketplace.
- Open your project in VS Code.
- Click the "Watch LESS" button at the bottom of the editor.
- The compiler will automatically generate a
style.css
file fromstyle.less
.
- Semantic HTML5 markup
- LESS (CSS Preprocessor)
- CSS Flexbox & Grid
- Vanilla JavaScript (ES6+)
- Mobile-first workflow
While working on this challenge, I improved my understanding of:
-
LESS Nesting & Variables:
@soft-red: hsl(14, 88%, 65%); .accordion-button { color: @soft-red; &:hover { font-weight: bold; color: darken(@soft-red, 10%); } }
-
JavaScript Accordion Functionality:
document.querySelectorAll(".accordion-header").forEach(header => { header.addEventListener("click", function () { this.classList.toggle("active"); this.nextElementSibling.style.display = this.classList.contains("active") ? "block" : "none"; }); });
- Improve ARIA accessibility for screen readers.
- Convert project to React with dynamic FAQ items.
- Use GSAP animations for smooth transitions.
- LESS Official Docs - Helped with understanding nesting and variables.
- CSS Tricks - Flexbox - Great for positioning elements.
- Frontend Mentor - Yashi-Singh-9
- LinkedIn - Yashi Singh
Big thanks to Frontend Mentor for providing awesome coding challenges! ๐