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

Accordion card using just CSS

@Jhemili

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


Hi, guys. I appreciate some feedback about the way I positioned the images and if there's a simpler way to code this.

Community feedback

@B1N4R1

Posted

Hi Jhemili,

Your solution looks great, just two things:

  • I would add an option to close the question you just opened because once you open a question you can no longer have all the questions closed, there will always be one open.

  • Work a bit more on the frontend to make it look more like the designs they give you: the spacing looks a bit off it should be consistant, the card's width on tablets looks a bit large.

Keep on the good work!

Cheers!

Marked as helpful

0

@Jhemili

Posted

@B1N4R1 I've thought about the closing option, but I couldn't find a solution using just css. Dou you have any ideia how this could be done? Thanks a lot.

0

@B1N4R1

Posted

@Jhemili You could convert your <div class="container"> to <a href="#" class="container"> then in the css you reset the anchor tags default styles like:

a{
   color: inherit;
   text-decoration: none;
}

So every time you click at the card the questions will close because the url of the site will change from #questionN to #, same will happen if you click on the opened question because the questions are children of the card so you are actually clicking the card too

Edit: This can vary, you could put the anchor tag as the wrapper of all the layout and instead of using the body to center everything use the achor tag

Cheers!

0
P
Chamu 12,970

@ChamuMutezva

Posted

@B1N4R1 this is not a reason to use an anchor tag

0

@B1N4R1

Posted

@ChamuMutezva You are absolutely right, I was just suggesting a way to do it just using CSS and this is a little "trick" or "hack" you can use. If it was me I would have used JS like I did in my solution to this challenge

Maybe there is another way to do it with CSS that I missed?

0

@B1N4R1

Posted

@ChamuMutezva You just revealed the world to me, didn't know about this element. You can do so much with it! Thanks!

0

@Jhemili

Posted

@ChamuMutezva Thanks a lot for the help. I just posted the second version. I fixed some layout problems, and used your suggestion about details and summary. The code is now more organized and responsive, hope you guys agree.

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