Design comparison
Solution retrospective
This is my second time uploading this challenge. I've managed to add some transition effect to the accordion using the element.style.maxHeight = element.scrollHeight + "px"
, but this effect only works when the accordion opens..but doesn't work when its closing. I'll be super grateful if anybody can teach me how to do it. 🙇🏾♂️
Update : made the javascript cleaner and added a little bit of transition effect using the opacity
property
Community feedback
- @NJVSPosted over 2 years ago
Hi, CSS
display
property cannot be animated. You can just setmax-height: 0
on your.faq-acc-answer
and do theelement.scrollHeight
, thenelement.removeAttribute("style")
to remove theelement.style.maxHeight
. I just submit my solution, you can check it if you want <3Marked as helpful0
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