Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 7 months ago

Faq accordion using Javascript

Camryn Tidsworth•130
@CamrynTidsworth
A solution to the FAQ accordion challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

This was my first project with Javascript so I am proud to pull that off. Next time, I will continue to define my responsive design and Javascript skills.

What challenges did you encounter, and how did you overcome them?

Initially, I was not sure how to center the faq component with flexbox while still allowing the page length to grow as the accordion opens (because I had been using "height: 100vh;" on the parent in order to center containers). After doing some digging online, I discovered that I could use "min-height: 100vh;" to allow the parent to grow with the content.

What specific areas of your project would you like help with?

Two things:

  1. Toggling the plus/minus icons: the only way I could find to toggle the plus/minus icons on each faq was to write a separate function for each question. Otherwise, the function would only toggle the top icon regardless of which question you clicked on. Does anyone know of a more efficient way to do this?

  2. I found that if I open and close the accordion repeatedly, the plus/minus icons eventually get out of sync. I would love to find a way to make my functions a little less breakable.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Camryn Tidsworth's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub