Submitted almost 2 years ago
FAQ Accordion Card with CSS and JavaScript
@AbibGuardian50
Design comparison
SolutionDesign
Solution retrospective
I have some question :
- How to make the arrow keep rotate on 180 deg while user click the question and back to default position while user close the question
Thank you and any feedback is welcome
Community feedback
- @EileenpkPosted almost 2 years ago
Hi Abieb, your code looks good. Here is how you can rotate the arrow onClick and rotate it back to starting position when its clicked again.
- Add a class of question to all the arrow images in the HTML.
- In your JavaScript do something like this to target all the arrow images.
const question = document.querySelectorAll('.question') question.forEach(el => { el.addEventListener('click', function (){ el.classList.toggle('upside-down'); }); });
- In your CSS add
.upside-down img{ transform: rotate(180deg); }
Here is a link that goes to my solution to this challenge if you want to see how I did it. https://github.com/Eileenpk/faq-accordion-card
If you found this helpful please mark it as such :)
- Let's connect on LinkedIn! - @Eileenpk
Marked as helpful0@AbibGuardian50Posted almost 2 years ago@Eileenpk HI sorry for my late answer i will give it a try for your answer thank you Eileen! Have a great day
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