Design comparison
Solution retrospective
Hi everybody!
I couldn't find a way to animate the height of the accordion content giving the auto value. Is there any way to do that?
I would really appreciate if you review my code anyway. π
Community feedback
- @RocTanweerPosted over 3 years ago
Hello π @Cornale
Nice π work βΊοΈ...!
When acc is opened, it's not closing...try removing line 12 of script.js and that should fix this. Remember when your are using element.classList.toggle(), you don't need to manually remove a class...it will do that itself.
What I would do in that situation is to add eventListener on the .accordian faq container, and in callBack function, loop through accordian-item and put this code in forEach callBack function ....
accordian-item.classList.contains('accordian-item--active') ? accordian-item.classList.remove('accordian-item--active') : accordian-item.classList.add('accordian-item--active');
Hope it helps π happy coding
0@mcornalePosted over 3 years agoHi @RocTanweer,
Thank you for checking my challenge.
In reality I don't close the open accordion on click on purpose, because I want always one accordion item open. In this way the height of the section is always the same, so the images don't move.
Btw you were right on the toggle, I forgot to change it after implementing the thing that I've just explained you, so thank you for pointing that out.
Happy coding to you too π
0
Please log in to post a comment
Log in with GitHubJoin 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