Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

FAQ accordion

AntennaeVY 110

@AntennaeVY

Desktop design screenshot for the FAQ accordion coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

I did it

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

None

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

How to animate the accordion & icon? the content snaps

Community feedback

Luke 140

@lukeSchwade

Posted

If you want to dip into JS, I used this tutorial which was pretty straightforward, and was a great way to learn about constructing objects.

A bug I ran into was the code uses element.offsetHeight, which doesn't include the margins of elements and the animation will be jerky if your <summary> and content is separated by a margin, so to fix it you have to add the elements margins into the calculation (hardcoded or otherwise), eg

const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;

had to be changed to

const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight + 16}px`;

(16px was height of my margin on <summary>, will be different if your elements have different margins in different places)

0

Please log in to post a comment

Log in with GitHub
Discord logo

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