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 Accordian

@AnoshaSohail

Desktop design screenshot for the FAQ accordion card coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hey community!

I'm seeking help with the following three things for this project:

How can I add a transition effect when opening an answer on a click event?

I need assistance with positioning the background image as per the design requirements.

How can I remove all previously applied classes from the previously clicked question when I click on a new one?

Any guidance or solutions for these tasks would be greatly appreciated. Thank you!

Community feedback

Account Deleted

Hey there! 👋

Congratulations on completing the challenge! 🎉

  • How can I add a transition effect when opening an answer on a click event?

Transitions don't work with height: auto and display, but you can use max-height. However, using max-height may not be a perfect solution either. Another option is to set a fixed height for the element in JavaScript.

  • I need assistance with positioning the background image as per the design requirements.

There are several ways to achieve this. For example, you can set the width of the block(screenshot) with the background and use a background image and positioning to place it in the right position.

background-image: url(illustration-desktop),url(pattern-desktop);

background-position: right [value], right [value];

  • How can I remove all previously applied classes from the previously clicked question when I click on a new one?

Without changing your code, then so:

if (previousQuestion && previousQuestion !== event.target) {
  previousQuestion.classList.remove('open')
  const parent = previousQuestion.closest('.accordian__item')
  parent.querySelector('.accordian__colapse').classList.remove('collapse') 
} 
  • Try not to use the .accordion__item h2 notation, instead you can set the styles for the h2 (if they are global) or use the .accordion__title class

  • Not recommended to use a <button> element directly inside an <h2> element

Why don't you use the shorthand notation for SCSS classes? .accordion { &__item {} }

If you have any questions or need further clarification, please don't hesitate to reach out to me.

Happy coding! 💻

Marked as helpful

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