Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

FAQ accordion card solution WORK IN PROGRESS

Alessandro•215
@alessandro-giuzio
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Always appreciate the help from the community

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Dave•5,295
    @dwhenson
    Posted over 3 years ago

    Hey @elsimater lovely work on this one! 🙌 The site looks great!

    One thing that really helped me with this one was the use of the details and summary HTML elements. This would be more semantic and easier to implement than using the buttons and `div's with set heights as you have a at the moment.

    This also has the advantage of including keyboard functionality and allow the key elements to be focusable automatically. The details and summary have much of the functionality baked in and can be styled with a little bit CSS work.

    If you went with this approach you can also animate the opening and closing pretty simply using some code like:

    details[open] summary ~ * {
    	animation: sweep 0.2s ease-out;
    	will-change: opacity, transform;
    }
    
    @keyframes sweep {
    	0% {
    		opacity: 0;
    		transform: translateY(-1em);
    	}
    
    	100% {
    		opacity: 1;
    		transform: translateY(0);
    	}
    }
    

    The styling of these elements can seem a bit complicated at first, but there are some good resources out there. Although there are some inconsistencies with Safari, it's not too bad. I am also battling with this at the moment in another challenge!

    The page is a bit of a mess but I have found the following page to be a pretty good guide in how to style things, including the triangle indicator: https://webdesign.tutsplus.com/tutorials/explaining-the-details-and-summary-elements--cms-21999

    Hope this help! Not an easy one this for sure!!

    Keep up the good work! 👍

    Cheers 👋

    Dave

    Marked as helpful
  • Marcus Hugo•365
    @marcus-hugo
    Posted over 3 years ago

    Looks good!

    I noticed the box svg is not centered when the accordion expands. You could try setting the .wrapper to align-items: baseline and then set the box svg position top: 7.4rem

    hope this helps!

    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub