Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 2 years ago

Accordion with css only, no javascript.

Sidney François•110
@sidneyfrancois
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


How can I ignore overflow: hidden from the parent div?

It worked when I set "position: fixed" in the box class but I don't think this would be an ideal solution... I was trying to make the position of the box relative to the image of woman.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Abdul Khaliq 🚀•72,360
    @0xabdulkhaliq
    Posted almost 2 years ago

    Hello there 👋. Congratulations on successfully completing the challenge! 🎉

    • I have other recommendations regarding your code that I believe will be of great interest to you.

    ACCORDION 🔴 :

    • The best way to go with creating the accordion elements in this challenge would be with the details and summary elements (or perhaps a combination of buttons and other elements).

    • They are already fairly accessible and provided a clean, semantic way to create accordion elements. I see you have used the div, label & input elements for the accordions, but those are not interactive or accessible by keyboard, so not all users will be able to open the accordions to see the content inside.

    • MDN's reference is a great place to start learning about the details and summary elements if you are interested.

    • If you have any questions or need further clarification, you can always check out my submission for this challenge and/or feel free to reach out to me.

    .

    I hope you find this helpful 😄 Above all, the solution you submitted is great !

    Happy coding!

  • Chanda•820
    @Chanda-Abdul
    Posted almost 2 years ago

    Hey there! Congratulations on completing your project.

    One way you could remove the overflow: hidden from the parent <div> is by creating a separate direct parent <div> specifically to contain the element that needs its overflow hidden.

    in the HTML:

    <div class="parent">
    <div class="child">
    <img src="img.jpg" alt="child-image">
    </div>
    </div>
    

    in the CSS:

    .parent{
    position: relative;  /* position may not be necessary */
    overflow: hidden;
    }
    
    .child{
    position: absolute;/* position may not be necessary */
    }
    

    By creating this nested structure, you can apply the overflow: hidden specifically to the desired container, allowing more flexibility for other elements within the parent <div>.

    You could also consider the tradeoffs of using overflow: hidden; to hide overflow on X and Y axis vs overflow-x: hidden; and overflow-y: hidden;

    Keep up the great work, and if you have any questions or need further clarification, feel free to reach out. Happy coding!

  • Qumrran•410
    @qumrran
    Posted almost 2 years ago

    I had a similar problem with this task. I used position: absolute, and it brought the element to the top. Like you, I have a feeling that it could have been done better.

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

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