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

Responsive accordion

P
Djole-zr 90

@Djole-zr

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


I having trouble making transition on opening and closing questions, can someone help me with that?

Community feedback

@ratul0407

Posted

@Djole-zr congrats on completing this challenge🎉🎉

There are quite a few ways to add transition on accordions. e.g.

  • You can use plain css to animate accordions first, create a new animation using @keyframes
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 100;
  }
}

Before you add the transition you should use a class add it on your p tag which doesn't have any class by default. It get's a .show tag when .question is clicked. We need to change it!. Add the following classes to it (answer, hidden).

.answer {
  opacity: 0;
  animation: fade-in 200ms ease 0ms 1 alternate forwards;
}

.hidden {
  display: hidden;
}

Then in js just toggle between hidden class whenever the question div is clicked

I hope you found this helpful👍👍

Have a nice day and happy coding my friend😄

1

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