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

FAQ Card

Trey•290
@willetto
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Update: Thank you for all the comments and links to helpful resources. I was able to fix both issues, although the animation isn't as smooth as I'd like it. I was able to implement a version of Christian's idea within my main element.

//Original Post I have two areas I need help in:

  1. How can you consistently place the floating box in about the right area?
  2. How can you change an element, like the answers, from display: hidden to display: grid and have it transition in nicely?

Thanks for your help and feedback!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Gilberto Fernández•60
    @gfernan24373
    Posted over 3 years ago

    Hey!! nicely done!!! I gonna submit this challenge in a couple of hours, it was so hard but no imposible positioning the @ box, you can use position relative and absolute with relative values for the properties like width, height and the position for the top, botton, right and left. Feel free to review this material that I founded to solve this issue https://codepen.io/graup/pen/EPjNwr.

    In the JS document you can set the properties for the faqs answers in this case p tags. I don't know why the js script file cannot read the properties in the css files directly. I founded sites explaining the getComputedStyle and getPropertyValue methods to read the properties in the .css file but looks to hard to implement. if you select a p tag like this in the js file:

    let faqs = document.querySelectorAll('.p-faq'); //Select all the p tags for (answer of faqs) { console.log(answer.style.display): } //Console =

    So... All the properties are empty and you need to set it again like this: for (answer of faqs) { answer.style.display = 'none'; } . . ...rest of the code here And now, you can do whatever you want.

    Marked as helpful
  • Christian Foster•270
    @fosteeco
    Posted over 3 years ago

    The way I'd fix this is by creating a wrapper around the main tag with the same width. .main-wrapper { position: relative; width: min(100% - 8rem, 920px); } This container wraps around the main tag so it's like this:

    <div class="main-wrapper"> <main class="container">...</main> </div>

    This should fix the issue. I created a pull request on your repo if you want to try this solution. Looks good though.

    One thing I think is an issue is the pulldowns extending the size of the container on smaller screens when they are opened. It seems kind of jarring.

    Marked as helpful
  • Kamasah-Dickson•5,570
    @Kamasah-Dickson
    Posted over 3 years ago

    Don't forget to add the box shadow to the main container

    Marked as helpful
  • Kamasah-Dickson•5,570
    @Kamasah-Dickson
    Posted over 3 years ago

    The img should have a position property of relative.

    And the box should have a position absolute Remember both the box and IMG should be in the same container.

    Also to the drop down it should have a height of 0px and visibility hidden.

    After that do something like this

    h1:active + p { height:the height u want; visibility: visible; }

    Create a CSS transition
    E.g @keyfram trans { NB: the "from" and "to" from{ opacity:0; Something else }

    To{ Opacity: Something else } }

    Don't forget to add the trans to the element u want to transit So your element { Transition trans 3s eas linear; }

    I hope u get it or u can learn from the link below

    https://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp

    Happy coding👍

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

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 all CSS, SCSS and Less files in your repository.

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.

How does the JavaScript validation report work?

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

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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

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