Responsive FAQ using flexbox and JS

Solution retrospective
Hi everyone, I am wondering if I have too much CSS code for such a project as I tried to make it responsive for all sizes.
What techniques, or methods could I follow/ read up on to make my code cleaner and more dry for the future?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @vanzasetia
👋 Hi Zach!
I have some feedback on this solution:
- Accessibility
- Use the native HTML tag to create the accordion,
details
andsummary
. This will make the assistive technology like screen-reader can understand that it is an accordion. - For any decorative images, each
img
tag should have emptyalt=""
andaria-hidden="true"
attributes to make all web assistive technology such as screen readers ignore those images. In this case, all images are decorative only. - Swap the attribution
div
withfooter
to fix the accessibility issue.
- Use the native HTML tag to create the accordion,
- Visual
- To make this website responsive:
- I would recommend letting the content inside the
container
control the height of thecontainer
. - Simplify the
@media
query, in this case, you don't need to care about the userheight
size. Focus on the width (min-width
, with mobile-first approach).
- I would recommend letting the content inside the
- The
background-color
of thecontainer
or the card should be white, which means you don't need anyfilter
property at all.
- To make this website responsive:
- JavaScript
- Don't use inline styling ( the same rule apply when writing JavaScript ). Use CSS classes to handle any styling and use JavaScript to add or remove the class.
- I would recommend using
forEach
instead offor loop
to make your JavaScript easier to understand. - I would recommend separating the classes for styling and for JavaScript by prefixing the class name with
js-
. Thejs-
classes are only for JavaScript purposes only ( no styling at all). This will make it easier to maintain, since if you want to change the styling, then the functionality will still remain.
That's it! Hopefully, this is helpful!
- Accessibility
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